MCPcopy
hub / github.com/unkeyed/unkey / TestMemoryCounter_SetIfNotExists

Function TestMemoryCounter_SetIfNotExists

pkg/counter/memory_test.go:90–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestMemoryCounter_SetIfNotExists(t *testing.T) {
91 c := NewMemory()
92 ctx := context.Background()
93
94 set, err := c.SetIfNotExists(ctx, "key1", 42)
95 require.NoError(t, err)
96 require.True(t, set)
97
98 set, err = c.SetIfNotExists(ctx, "key1", 99)
99 require.NoError(t, err)
100 require.False(t, set)
101
102 got, err := c.Get(ctx, "key1")
103 require.NoError(t, err)
104 require.Equal(t, int64(42), got)
105}
106
107func TestMemoryCounter_Delete(t *testing.T) {
108 c := NewMemory()

Callers

nothing calls this directly

Calls 3

NewMemoryFunction · 0.70
SetIfNotExistsMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected