Skip to content

Commit

Permalink
Revert "Allow skipping http client init with flag"
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtaylor authored Jul 24, 2023
1 parent 2df459f commit 8470b12
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 51 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ Supposing you are using [mox](https://github.com/dashbitco/mox), you can do some
```elixir
# in test_helper.exs
Mox.defmock(HTTPClientMock, for: Snap.HTTPClient)
Mox.stub(HTTPClientMock, :child_spec, fn _config -> :skip end)

# in config/test.exs
config :my_app, MyApp.Cluster,
http_client_adapter: HTTPClientMock,
skip_initialize_http_client: true
config :my_app, MyApp.Cluster, http_client_adapter: HTTPClientMock

# in a test file
Mox.expect(HTTPClientMock, :request, fn _cluster, _method, _url, _headers, _body, _opts ->
Mox.expect(HTTPClientMock, :request, fn _cluster, _method, _url, _headers, _body, _opts
body = "{}" # valid json
{:ok, %Snap.HTTPClient.Response{status: 200, headers: [], body: body}}
end)
Expand Down
10 changes: 3 additions & 7 deletions lib/snap/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@ defmodule Snap.Cluster.Supervisor do
defp maybe_initialize_http_client(cluster, config) do
config = Keyword.put(config, :cluster, cluster)

if config[:skip_initialize_http_client] do
[]
else
case HTTPClient.child_spec(config) do
:skip -> []
http_client_child_spec -> [http_client_child_spec]
end
case HTTPClient.child_spec(config) do
:skip -> []
http_client_child_spec -> [http_client_child_spec]
end
end
end
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ defmodule Snap.MixProject do
{:telemetry, "~> 1.0 or ~> 0.4"},
{:ex_doc, "~> 0.23", only: :dev, runtime: false},
{:dialyxir, "~> 1.0", only: :dev, runtime: false},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:mox, "~> 1.0", only: :test}
{:credo, "~> 1.5", only: [:dev, :test], runtime: false}
]
end

Expand Down
1 change: 0 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"mime": {:hex, :mime, "2.0.3", "3676436d3d1f7b81b5a2d2bd8405f412c677558c81b1c92be58c00562bb59095", [:mix], [], "hexpm", "27a30bf0db44d25eecba73755acf4068cbfe26a4372f9eb3e4ea3a45956bff6b"},
"mint": {:hex, :mint, "1.5.1", "8db5239e56738552d85af398798c80648db0e90f343c8469f6c6d8898944fb6f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4a63e1e76a7c3956abd2c72f370a0d0aecddc3976dea5c27eccbecfa5e7d5b1e"},
"mox": {:hex, :mox, "1.0.2", "dc2057289ac478b35760ba74165b4b3f402f68803dd5aecd3bfd19c183815d64", [:mix], [], "hexpm", "f9864921b3aaf763c8741b5b8e6f908f44566f1e427b2630e89e9a73b981fef2"},
"nimble_options": {:hex, :nimble_options, "1.0.1", "b448018287b22584e91b5fd9c6c0ad717cb4bcdaa457957c8d57770f56625c43", [:mix], [], "hexpm", "078b2927cd9f84555be6386d56e849b0c555025ecccf7afee00ab6a9e6f63837"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"nimble_pool": {:hex, :nimble_pool, "1.0.0", "5eb82705d138f4dd4423f69ceb19ac667b3b492ae570c9f5c900bb3d2f50a847", [:mix], [], "hexpm", "80be3b882d2d351882256087078e1b1952a28bf98d0a287be87e4a24a710b67a"},
Expand Down
34 changes: 0 additions & 34 deletions test/mox_test.exs

This file was deleted.

3 changes: 0 additions & 3 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
ExUnit.configure(exclude: [integration: true])

Mox.defmock(HTTPClientMock, for: Snap.HTTPClient)

ExUnit.start()

url = "http://localhost:9200"
Expand Down

0 comments on commit 8470b12

Please sign in to comment.