MCPcopy Index your code
hub / github.com/coder/coder / TestExtractContext

Function TestExtractContext

agent/agentchat/headers_test.go:16–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestExtractContext(t *testing.T) {
17 t.Parallel()
18
19 validID := uuid.MustParse("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
20 ancestor1 := uuid.MustParse("11111111-2222-3333-4444-555555555555")
21 ancestor2 := uuid.MustParse("66666666-7777-8888-9999-aaaaaaaaaaaa")
22
23 tests := []struct {
24 name string
25 chatID string // empty means header not set
26 setChatID bool // whether to set the chat ID header at all
27 ancestors string // empty means header not set
28 setAncestors bool // whether to set the ancestor header at all
29 wantChatID uuid.UUID
30 wantAncestorIDs []uuid.UUID
31 wantOK bool
32 }{
33 {
34 name: "NoHeadersPresent",
35 setChatID: false,
36 setAncestors: false,
37 wantChatID: uuid.Nil,
38 wantAncestorIDs: nil,
39 wantOK: false,
40 },
41 {
42 name: "ValidChatID_NoAncestors",
43 chatID: validID.String(),
44 setChatID: true,
45 setAncestors: false,
46 wantChatID: validID,
47 wantAncestorIDs: []uuid.UUID{},
48 wantOK: true,
49 },
50 {
51 name: "ValidChatID_ValidAncestors",
52 chatID: validID.String(),
53 setChatID: true,
54 ancestors: mustMarshalJSON(t, []string{
55 ancestor1.String(),
56 ancestor2.String(),
57 }),
58 setAncestors: true,
59 wantChatID: validID,
60 wantAncestorIDs: []uuid.UUID{ancestor1, ancestor2},
61 wantOK: true,
62 },
63 {
64 name: "MalformedChatID",
65 chatID: "not-a-uuid",
66 setChatID: true,
67 setAncestors: false,
68 wantChatID: uuid.Nil,
69 wantAncestorIDs: nil,
70 wantOK: false,
71 },
72 {
73 name: "ValidChatID_MalformedAncestorJSON",

Callers

nothing calls this directly

Calls 6

mustMarshalJSONFunction · 0.85
extractContextForTestFunction · 0.85
RunMethod · 0.65
SetMethod · 0.65
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected