TestCache_CaseInsensitive verifies that case-insensitive matching is the default when CaseSensitive is false.
(t *testing.T)
| 84 | // TestCache_CaseInsensitive verifies that case-insensitive matching is the |
| 85 | // default when CaseSensitive is false. |
| 86 | func 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. |
nothing calls this directly
no test coverage detected