Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change struct to map in order to make dynamic connections (including tests) #30

Merged

Conversation

jaeyson
Copy link
Owner

@jaeyson jaeyson commented Jun 30, 2024

Fixes #26

Problem

Setting the credentials dynamically won't work since the Connection module by default is a struct (hence, compile time).

This also affects the test files of the library, since it relies on explicit connection string. Leaving it blank will throw an error.

To reproduce:

  1. open shell in test env: MIX_ENV=test iex -S mix
  2. put env in application:
Application.put_all_env(
  ex_typesense: [
    api_key: "xyz",
    host: "localhost",
    port: 8108,
    scheme: "http"
  ]
)
  1. run ExTypesense.Connection.new
  2. The Connection struct field values returns nil.

Workaround

Since the problem came from making the connection a struct, it defeats the purpose of making it dynamic (runtime). So we have to change it from struct to map.

@jaeyson jaeyson added bug Something isn't working documentation Improvements or additions to documentation labels Jun 30, 2024
@jaeyson jaeyson self-assigned this Jun 30, 2024
@jaeyson jaeyson linked an issue Jun 30, 2024 that may be closed by this pull request
@jaeyson jaeyson changed the title Update readme for setting up connections in test.exs Change struct to map in order to make dynamic connections (including tests) Jun 30, 2024
@jaeyson jaeyson merged commit 7838016 into main Jul 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

ExTypesense.Connection.new doesn't work with MIX_ENV=test
1 participant