Skip to content

Commit

Permalink
clear registry before all test
Browse files Browse the repository at this point in the history
  • Loading branch information
kp-cat committed Sep 23, 2024
1 parent 03938e6 commit fff2c50
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ defmodule ConfigCat.IntegrationTest do

@sdk_key "configcat-sdk-1/PKDVCLf-Hq-h-kCzMp-L7Q/1cGEJXUwYUGZCBOL-E2sOw"

setup_all do
# Restart the Registry before running tests
clear_registry()

:ok
end

setup context do
# This will run after every individual test
on_exit(fn ->
Expand Down Expand Up @@ -201,6 +208,17 @@ defmodule ConfigCat.IntegrationTest do
pattern = [{{{__MODULE__, :"$1"}, :"$2", :"$3"}, [], [{{:"$1", :"$2", :"$3"}}]}]
# Select all items from the registry
registry_items = Registry.select(ConfigCat.Registry, pattern)
IO.puts("Registry: #{inspect(registry_items)}")
IO.puts("print_registry_contents: #{inspect(registry_items)}")
end

defp clear_registry do
# Define a pattern to match all entries in the registry
pattern = [{{{__MODULE__, :"$1"}, :_, :_}, [], [{{:"$1"}}]}]
# Select all items from the registry
keys = Registry.select(ConfigCat.Registry, pattern)
# Unregister each key
Enum.each(keys, fn key ->
Registry.unregister(ConfigCat.Registry, key)
end)
end
end

0 comments on commit fff2c50

Please sign in to comment.