Skip to content

Commit

Permalink
Merge pull request #723 from pow-auth/clean-up-mnesia-tests
Browse files Browse the repository at this point in the history
Clean up mnesia tests
  • Loading branch information
danschultzer authored Feb 8, 2024
2 parents c0c768d + ab89cc8 commit 2742e76
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/pow/store/backend/mnesia_cache_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ defmodule Pow.Store.Backend.MnesiaCacheTest do

# Set short TTL on node a
flush_process_mailbox()
config = Config.put(@default_config, :ttl, 100)
config = Config.put(@default_config, :ttl, @assertion_timeout)
assert :rpc.call(node_a, MnesiaCache, :put, [config, {"short_ttl_key_set_on_a", "value"}])
assert_receive {{:mnesia, ^node_b}, {:mnesia_system_event, {:mnesia_user, {:refresh_invalidators, {_, _}}}}}
assert_receive {{:mnesia, ^node_b}, {:mnesia_system_event, {:mnesia_user, {:refresh_invalidators, {_, _}}}}}, @assertion_timeout

# Stop node a
flush_process_mailbox()
Expand All @@ -241,7 +241,7 @@ defmodule Pow.Store.Backend.MnesiaCacheTest do

# Ensure that node b invalidates with TTL set on node a
assert :rpc.call(node_b, MnesiaCache, :get, [config, "short_ttl_key_set_on_a"]) == "value"
assert_receive {{:mnesia, ^node_b}, {:mnesia_table_event, {:delete, {MnesiaCache, [_, "short_ttl_key_set_on_a"]}, _}}}, @assertion_timeout
assert_receive {{:mnesia, ^node_b}, {:mnesia_table_event, {:delete, {MnesiaCache, [_, "short_ttl_key_set_on_a"]}, _}}}, @assertion_timeout + 100
assert :rpc.call(node_b, MnesiaCache, :get, [config, "short_ttl_key_set_on_a"]) == :not_found

# Start node a but not mnesia yet before we test cross node TTL
Expand Down Expand Up @@ -560,8 +560,9 @@ defmodule Pow.Store.Backend.MnesiaCacheTest do
rpc(node, Application, :ensure_all_started, [app_name])
end

# Remove logger to prevent logs
rpc(node, Logger, :remove_backend, [:console])
# Silence console logging on node
rpc(node, :logger, :remove_handler, [:default])
rpc(node, Logger, :remove_backend, [:console]) # TODO: Remove when Elixir 1.15 is required

add_listener_module(node)

Expand Down

0 comments on commit 2742e76

Please sign in to comment.