Skip to content

Commit

Permalink
test add with expired keys
Browse files Browse the repository at this point in the history
Signed-off-by: kmpm <me@kmpm.se>
  • Loading branch information
kmpm committed May 8, 2024
1 parent 9869144 commit 9e4c662
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/impl/pure/cache_memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ compaction_interval: 1ns

_, err = c.Get(ctx, "bar")
assert.Equal(t, service.ErrKeyNotFound, err)

// Add with static keys should trigger completion after exdpiry.
d := time.Millisecond * 50
err = c.Add(ctx, "foo", []byte("3"), &d)
require.NoError(t, err)

_, err = c.Get(ctx, "foo")
require.NoError(t, err)

err = c.Add(ctx, "foo", []byte("4"), &d)
assert.Equal(t, service.ErrKeyAlreadyExists, err)

<-time.After(time.Millisecond * 50)

err = c.Add(ctx, "foo", []byte("4"), &d)
require.NoError(t, err)

}

func TestMemoryCacheInitValues(t *testing.T) {
Expand Down

0 comments on commit 9e4c662

Please sign in to comment.