Skip to content

Commit

Permalink
add failing test example
Browse files Browse the repository at this point in the history
  • Loading branch information
khaskelberg committed Jun 28, 2022
1 parent 340e669 commit 49438f8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/shared/local_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ defmodule Nebulex.LocalTest do
refute cache.get(:counter_with_ttl)
end

test "incr initializes default value if ttl is expired", %{cache: cache} do
assert cache.incr(:another_counter_with_ttl, 1, ttl: 1000) == 1
assert cache.incr(:another_counter_with_ttl) == 2

:ok = Process.sleep(1010)
assert cache.incr(:another_counter_with_ttl, 1, ttl: 1000) == 1
end

test "incr existing entry", %{cache: cache} do
assert cache.put(:counter, 0) == :ok
assert cache.incr(:counter) == 1
Expand Down

0 comments on commit 49438f8

Please sign in to comment.