From fff2c504960de07a482e56b41b8e4cfd7059cb34 Mon Sep 17 00:00:00 2001 From: kp-cat <52385411+kp-cat@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:31:03 +0200 Subject: [PATCH] clear registry before all test --- test/integration_test.exs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/integration_test.exs b/test/integration_test.exs index 13bd4d2..3b7ee64 100644 --- a/test/integration_test.exs +++ b/test/integration_test.exs @@ -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 -> @@ -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