findUserMessage returns the first user-role message from a slice of chat messages, failing the test if none is found.
(t testing.TB, messages []database.ChatMessage)
| 134 | // findUserMessage returns the first user-role message from a slice of chat |
| 135 | // messages, failing the test if none is found. |
| 136 | func findUserMessage(t testing.TB, messages []database.ChatMessage) database.ChatMessage { |
| 137 | t.Helper() |
| 138 | idx := slices.IndexFunc(messages, func(m database.ChatMessage) bool { |
| 139 | return m.Role == database.ChatMessageRoleUser |
| 140 | }) |
| 141 | require.NotEqual(t, -1, idx, "expected to find a user message") |
| 142 | return messages[idx] |
| 143 | } |
| 144 | |
| 145 | type failNextChatSystemPromptStore struct { |
| 146 | database.Store |
no test coverage detected