MCPcopy Create free account
hub / github.com/coder/coder / TestChatGPTSearch_TemplateSearch

Function TestChatGPTSearch_TemplateSearch

codersdk/toolsdk/chatgpt_test.go:19–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestChatGPTSearch_TemplateSearch(t *testing.T) {
20 t.Parallel()
21
22 tests := []struct {
23 name string
24 query string
25 setupTemplates int
26 expectError bool
27 errorContains string
28 }{
29 {
30 name: "ValidTemplatesQuery_MultipleTemplates",
31 query: "templates",
32 setupTemplates: 3,
33 expectError: false,
34 },
35 {
36 name: "ValidTemplatesQuery_NoTemplates",
37 query: "templates",
38 setupTemplates: 0,
39 expectError: false,
40 },
41 }
42
43 for _, tt := range tests {
44 t.Run(tt.name, func(t *testing.T) {
45 t.Parallel()
46
47 // Setup
48 client, store := coderdtest.NewWithDatabase(t, nil)
49 owner := coderdtest.CreateFirstUser(t, client)
50
51 // Create templates as needed
52 var expectedTemplates []database.Template
53 for i := 0; i < tt.setupTemplates; i++ {
54 template := dbfake.TemplateVersion(t, store).
55 Seed(database.TemplateVersion{
56 OrganizationID: owner.OrganizationID,
57 CreatedBy: owner.UserID,
58 }).Do()
59 expectedTemplates = append(expectedTemplates, template.Template)
60 }
61
62 // Create tool dependencies
63 deps, err := toolsdk.NewDeps(client)
64 require.NoError(t, err)
65
66 // Execute tool
67 args := toolsdk.SearchArgs{Query: tt.query}
68 result, err := testTool(t, toolsdk.ChatGPTSearch, deps, args)
69
70 // Verify results
71 if tt.expectError {
72 require.Error(t, err)
73 if tt.errorContains != "" {
74 require.Contains(t, err.Error(), tt.errorContains)
75 }
76 return

Callers

nothing calls this directly

Calls 13

NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
TemplateVersionFunction · 0.92
NewDepsFunction · 0.92
testToolFunction · 0.85
NotEmptyMethod · 0.80
RunMethod · 0.65
DoMethod · 0.65
SeedMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected