MCPcopy Create free account
hub / github.com/coder/aibridge / TestRecordPrompt

Function TestRecordPrompt

intercept/responses/base_test.go:17–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestRecordPrompt(t *testing.T) {
18 t.Parallel()
19
20 tests := []struct {
21 name string
22 promptWasRecorded bool
23 prompt string
24 responseID string
25 wantRecorded bool
26 wantPrompt string
27 }{
28 {
29 name: "records_prompt_successfully",
30 prompt: "tell me a joke",
31 responseID: "resp_123",
32 wantRecorded: true,
33 wantPrompt: "tell me a joke",
34 },
35 {
36 name: "records_empty_prompt_successfully",
37 prompt: "",
38 responseID: "resp_123",
39 wantRecorded: true,
40 wantPrompt: "",
41 },
42 {
43 name: "skips_recording_on_empty_response_id",
44 prompt: "tell me a joke",
45 responseID: "",
46 wantRecorded: false,
47 },
48 }
49
50 for _, tc := range tests {
51 t.Run(tc.name, func(t *testing.T) {
52 t.Parallel()
53
54 rec := &testutil.MockRecorder{}
55 id := uuid.New()
56 base := &responsesInterceptionBase{
57 id: id,
58 recorder: rec,
59 logger: slog.Make(),
60 }
61
62 base.recordUserPrompt(t.Context(), tc.responseID, tc.prompt)
63
64 prompts := rec.RecordedPromptUsages()
65 if tc.wantRecorded {
66 require.Len(t, prompts, 1)
67 require.Equal(t, id.String(), prompts[0].InterceptionID)
68 require.Equal(t, tc.responseID, prompts[0].MsgID)
69 require.Equal(t, tc.wantPrompt, prompts[0].Prompt)
70 } else {
71 require.Empty(t, prompts)
72 }
73 })
74 }

Callers

nothing calls this directly

Calls 2

recordUserPromptMethod · 0.95
RecordedPromptUsagesMethod · 0.95

Tested by

no test coverage detected