26f897c1ec
release / release-please (push) Failing after 1m49s
docs / build (push) Failing after 6m34s
release / build-and-upload (arm64, linux) (push) Has been cancelled
release / build-and-upload (arm64, windows) (push) Has been cancelled
release / build-darwin (amd64, darwin) (push) Has been cancelled
release / checksums (push) Has been cancelled
release / finalize (push) Has been cancelled
release / build-darwin (arm64, darwin) (push) Has been cancelled
release / build-and-upload (amd64, linux) (push) Has been cancelled
release / build-and-upload (amd64, windows) (push) Has been cancelled
docs / deploy (push) Has been cancelled
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package intent
|
|
|
|
import "testing"
|
|
|
|
func TestMemCache_GetPut(t *testing.T) {
|
|
c := NewMemCache()
|
|
if _, ok := c.Get("missing"); ok {
|
|
t.Error("missing key should return ok=false")
|
|
}
|
|
c.Put("k", "summary", "claude", "sess-1")
|
|
got, ok := c.Get("k")
|
|
if !ok || got != "summary" {
|
|
t.Errorf("got (%q, %v), want (summary, true)", got, ok)
|
|
}
|
|
}
|
|
|
|
func TestCacheKeyFor_DistinguishesSessionGrowth(t *testing.T) {
|
|
a := &Session{AgentName: "claude", SessionID: "s1", LastMsgKey: "k1", Messages: []Message{{}}}
|
|
b := &Session{AgentName: "claude", SessionID: "s1", LastMsgKey: "k1", Messages: []Message{{}, {}}}
|
|
if cacheKeyFor(a) == cacheKeyFor(b) {
|
|
t.Error("session growth must change the cache key")
|
|
}
|
|
}
|
|
|
|
func TestCacheKeyFor_StableForSameSession(t *testing.T) {
|
|
a := &Session{AgentName: "claude", SessionID: "s1", LastMsgKey: "k1", Messages: []Message{{Text: "x"}}}
|
|
b := &Session{AgentName: "claude", SessionID: "s1", LastMsgKey: "k1", Messages: []Message{{Text: "y"}}}
|
|
if cacheKeyFor(a) != cacheKeyFor(b) {
|
|
t.Error("identical metadata must produce the same cache key")
|
|
}
|
|
}
|