@@ -106,9 +106,11 @@ func TestChatGPTSearch_TemplateMultipleFilters(t *testing.T) {
106
106
// Setup
107
107
client , store := coderdtest .NewWithDatabase (t , nil )
108
108
owner := coderdtest .CreateFirstUser (t , client )
109
+ org2 := dbgen .Organization (t , store , database.Organization {
110
+ Name : "org2" ,
111
+ })
109
112
110
- // Create templates directly with specific names for testing filters
111
- dockerTemplate1 := dbgen .Template (t , store , database.Template {
113
+ dbgen .Template (t , store , database.Template {
112
114
OrganizationID : owner .OrganizationID ,
113
115
CreatedBy : owner .UserID ,
114
116
Name : "docker-development" , // Name contains "docker"
@@ -118,7 +120,7 @@ func TestChatGPTSearch_TemplateMultipleFilters(t *testing.T) {
118
120
119
121
// Create another template that doesn't contain "docker"
120
122
dbgen .Template (t , store , database.Template {
121
- OrganizationID : owner . OrganizationID ,
123
+ OrganizationID : org2 . ID ,
122
124
CreatedBy : owner .UserID ,
123
125
Name : "python-web" , // Name doesn't contain "docker"
124
126
DisplayName : "Python Web" ,
@@ -127,7 +129,7 @@ func TestChatGPTSearch_TemplateMultipleFilters(t *testing.T) {
127
129
128
130
// Create third template with "docker" in name
129
131
dockerTemplate2 := dbgen .Template (t , store , database.Template {
130
- OrganizationID : owner . OrganizationID ,
132
+ OrganizationID : org2 . ID ,
131
133
CreatedBy : owner .UserID ,
132
134
Name : "old-docker-template" , // Name contains "docker"
133
135
DisplayName : "Old Docker Template" ,
@@ -138,27 +140,15 @@ func TestChatGPTSearch_TemplateMultipleFilters(t *testing.T) {
138
140
deps , err := toolsdk .NewDeps (client )
139
141
require .NoError (t , err )
140
142
141
- // Execute tool with name filter - should only return templates with "docker" in name
142
- args := toolsdk.SearchArgs {Query : "templates/name:docker" }
143
+ args := toolsdk.SearchArgs {Query : "templates/name:docker organization:org2" }
143
144
result , err := testTool (t , toolsdk .ChatGPTSearch , deps , args )
144
145
145
146
// Verify results
146
147
require .NoError (t , err )
147
- require .Len (t , result .Results , 2 , "Should match both docker templates" )
148
-
149
- // Validate the results contain both docker templates
150
- templateIDs := make (map [string ]bool )
151
- for _ , item := range result .Results {
152
- require .NotEmpty (t , item .ID )
153
- require .Contains (t , item .ID , "template:" )
154
- require .Contains (t , item .URL , "/templates/" )
155
- templateIDs [item .ID ] = true
156
- }
148
+ require .Len (t , result .Results , 1 , "Should match only the docker template in org2" )
157
149
158
- expectedID1 := "template:" + dockerTemplate1 .ID .String ()
159
- expectedID2 := "template:" + dockerTemplate2 .ID .String ()
160
- require .True (t , templateIDs [expectedID1 ], "Should contain first docker template" )
161
- require .True (t , templateIDs [expectedID2 ], "Should contain second docker template" )
150
+ expectedID := "template:" + dockerTemplate2 .ID .String ()
151
+ require .Equal (t , expectedID , result .Results [0 ].ID , "Should match the docker template in org2" )
162
152
}
163
153
164
154
func TestChatGPTSearch_WorkspaceSearch (t * testing.T ) {
0 commit comments