MCPcopy Index your code
hub / github.com/docker/docker-agent / TestCache_CaseInsensitive

Function TestCache_CaseInsensitive

pkg/runtime/cache_test.go:86–117  ·  view source on GitHub ↗

TestCache_CaseInsensitive verifies that case-insensitive matching is the default when CaseSensitive is false.

(t *testing.T)

Source from the content-addressed store, hash-verified

84// TestCache_CaseInsensitive verifies that case-insensitive matching is the
85// default when CaseSensitive is false.
86func TestCache_CaseInsensitive(t *testing.T) {
87 t.Parallel()
88
89 c, err := cache.New(cache.Config{Enabled: true, CaseSensitive: false})
90 require.NoError(t, err)
91
92 stream := newStreamBuilder().
93 AddContent("Hi there!").
94 AddStopWithUsage(5, 3).
95 Build()
96 prov := &messageRecordingProvider{
97 id: "test/mock-model",
98 streams: []*mockStream{stream},
99 }
100
101 // First turn: "Hello" → model is called.
102 sess1 := session.New(session.WithUserMessage("Hello"))
103 runWithCache(t, c, prov, sess1)
104
105 prov.mu.Lock()
106 require.Len(t, prov.recordedMessages, 1)
107 prov.mu.Unlock()
108
109 // Second turn: "HELLO" must still hit the cache.
110 sess2 := session.New(session.WithUserMessage("HELLO"))
111 runWithCache(t, c, prov, sess2)
112
113 prov.mu.Lock()
114 defer prov.mu.Unlock()
115 assert.Len(t, prov.recordedMessages, 1, "case-insensitive cache must hit on different case")
116 assert.True(t, hasAssistantMessage(sess2, "Hi there!"), "expected cached response to be replayed")
117}
118
119// TestCache_TrimSpaces verifies that whitespace trimming is applied when
120// TrimSpaces is enabled.

Callers

nothing calls this directly

Calls 12

NewFunction · 0.92
NewFunction · 0.92
WithUserMessageFunction · 0.92
newStreamBuilderFunction · 0.85
runWithCacheFunction · 0.85
hasAssistantMessageFunction · 0.85
AddStopWithUsageMethod · 0.80
LenMethod · 0.65
BuildMethod · 0.45
AddContentMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected