Skip to content

Commit

Permalink
add test to cover code
Browse files Browse the repository at this point in the history
  • Loading branch information
dongfuye committed Jan 14, 2023
1 parent 9c4992a commit 66eb2d1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/nebulex/adapters/local/generation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,26 @@ defmodule Nebulex.Adapters.Local.GenerationTest do
end
end

describe "cleanup cover" do
test "cleanup when gc_interval not set" do
{:ok, _pid} =
LocalWithSizeLimit.start_link(
max_size: 3,
gc_cleanup_min_timeout: 1000,
gc_cleanup_max_timeout: 1500
)

# Put some entries to exceed the max size
_ = cache_put(LocalWithSizeLimit, 1..4)

# Wait the max cleanup timeout
:ok = Process.sleep(1600)

# assert not crashed
assert LocalWithSizeLimit.count_all() == 4
end
end

## Private Functions

defp check_cache_size(cache) do
Expand Down

0 comments on commit 66eb2d1

Please sign in to comment.