MCPcopy Create free account
hub / github.com/UiPath/uipathcli / TestGetReturnsDataWhenSet

Function TestGetReturnsDataWhenSet

cache/file_cache_test.go:25–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestGetReturnsDataWhenSet(t *testing.T) {
26 cache := NewFileCache()
27
28 key := randomKey()
29 expiry := time.Now().UTC().Add(time.Second * 30)
30
31 cache.Set(key, "my-value", expiry)
32 value, expiresAt := cache.Get(key)
33
34 if value != "my-value" {
35 t.Errorf("Should return data from cache, but got: %v", value)
36 }
37 if expiry.Unix() != expiresAt.Unix() {
38 t.Errorf("Should return expiry value %v, but got: %v", expiry.Unix(), expiresAt.Unix())
39 }
40}
41
42func TestGetDoesNotReturnExpiredData(t *testing.T) {
43 cache := NewFileCache()

Callers

nothing calls this directly

Calls 5

SetMethod · 0.95
GetMethod · 0.95
NewFileCacheFunction · 0.85
randomKeyFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected