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

ExTypesense.Connection.new doesn't work with MIX_ENV=test #26

Closed
rodesousa opened this issue Jun 24, 2024 · 3 comments · Fixed by #30
Closed

ExTypesense.Connection.new doesn't work with MIX_ENV=test #26

rodesousa opened this issue Jun 24, 2024 · 3 comments · Fixed by #30
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@rodesousa
Copy link

rodesousa commented Jun 24, 2024

elixir version: 1.15.4
ex_typesense version: 0.4

I configure ex typesense into runtime.exs. But when I run test all of data from ExTypesense.Connection.new is nil
I put the configuration into test.exs but no effect

Screenshot from 2024-06-24 15-29-49
Screenshot from 2024-06-24 15-30-25

@jaeyson
Copy link
Owner

jaeyson commented Jun 25, 2024

Hi @rodesousa 👋

I missed that part. Thanks for letting me know!

@jaeyson jaeyson self-assigned this Jun 25, 2024
@jaeyson jaeyson added bug Something isn't working documentation Improvements or additions to documentation labels Jun 25, 2024
@jaeyson
Copy link
Owner

jaeyson commented Jun 30, 2024

@rodesousa kindly check this PR #30. Let me know if this fixes your issue.

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.

@rodesousa
Copy link
Author

@jaeyson It works ! :)

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 a pull request may close this issue.

2 participants