From 49438f8eeb40f90d90af51a7e4151f8bc995e96f Mon Sep 17 00:00:00 2001 From: khaskelberg Date: Tue, 28 Jun 2022 23:12:11 +0300 Subject: [PATCH] add failing test example --- test/shared/local_test.exs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/shared/local_test.exs b/test/shared/local_test.exs index 6f4303f2..253b96d5 100644 --- a/test/shared/local_test.exs +++ b/test/shared/local_test.exs @@ -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