-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from shijithkjayan/shijith-k/add-configurable-…
…options-for-http-client feat(config): ✅ Add options configuration for HTTP client
- Loading branch information
Showing
4 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
defmodule ExTypesense.HttpClientTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias ExTypesense.HttpClient | ||
|
||
setup do | ||
# Backup the original configuration | ||
original_config = Application.get_env(:ex_typesense, :options, %{}) | ||
|
||
on_exit(fn -> | ||
# Restore the original configuration after each test | ||
Application.put_env(:ex_typesense, :options, original_config) | ||
end) | ||
end | ||
|
||
describe "get_options/0" do | ||
test "returns the configured options" do | ||
Application.put_env(:ex_typesense, :options, %{ | ||
finch: MyApp.CustomFinch, | ||
receive_timeout: 5000 | ||
}) | ||
|
||
assert HttpClient.get_options() == %{finch: MyApp.CustomFinch, receive_timeout: 5000} | ||
end | ||
|
||
test "returns an empty map if options is not configured" do | ||
Application.delete_env(:ex_typesense, :options) | ||
|
||
assert HttpClient.get_options() == %{} | ||
end | ||
end | ||
end |