Skip to content

Instantly share code, notes, and snippets.

@oliveigah
Last active March 19, 2024 00:33
Show Gist options
  • Save oliveigah/a7cf1c7931440ba6c647866fd3e99d74 to your computer and use it in GitHub Desktop.
Save oliveigah/a7cf1c7931440ba6c647866fd3e99d74 to your computer and use it in GitHub Desktop.
test "get pool status with raise before checkin", %{finch_name: finch_name} do
stub(Mint.HTTP, :request, fn _, _, _, _, _ ->
raise "unexpected error"
end)
start_supervised!(
{Finch,
name: finch_name,
pools: %{
default: [
protocols: [:http1],
start_pool_metrics?: true,
size: 10
]
}}
)
url = "http://raise.com"
shp = {:http, "raise.com", 80}
Enum.map(1..20, fn _idx ->
assert_raise(RuntimeError, fn ->
Finch.build(:get, url) |> Finch.request(finch_name)
end)
end)
wait_connection_checkin()
assert {:ok,
[
%PoolMetrics{
pool_index: 1,
pool_size: 10,
available_connections: 10,
in_use_connections: 0
}
]} = Finch.get_pool_status(finch_name, shp)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment