MCPcopy
hub / github.com/OpenNHP/opennhp / TestTokenStore_StoreAndLoad

Function TestTokenStore_StoreAndLoad

nhp/test/tokenstore_test.go:21–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func TestTokenStore_StoreAndLoad(t *testing.T) {
22 ts := common.NewTokenStore[*testEntry]()
23
24 entry := &testEntry{value: "test-value", expireTime: time.Now().Add(1 * time.Hour)}
25 token := "abcd1234token"
26
27 ts.Store(token, entry)
28
29 loaded, found := ts.Load(token)
30 if !found {
31 t.Fatal("expected to find stored token")
32 }
33 if loaded.value != "test-value" {
34 t.Errorf("expected value 'test-value', got '%s'", loaded.value)
35 }
36}
37
38func TestTokenStore_LoadNotFound(t *testing.T) {
39 ts := common.NewTokenStore[*testEntry]()

Callers

nothing calls this directly

Calls 3

StoreMethod · 0.80
LoadMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected