(t *testing.T)
| 152 | } |
| 153 | |
| 154 | func TestChatGPTSearch_WorkspaceSearch(t *testing.T) { |
| 155 | t.Parallel() |
| 156 | |
| 157 | tests := []struct { |
| 158 | name string |
| 159 | query string |
| 160 | setupOwner string // "self" or "other" |
| 161 | setupWorkspace bool |
| 162 | expectError bool |
| 163 | errorContains string |
| 164 | }{ |
| 165 | { |
| 166 | name: "ValidWorkspacesQuery_CurrentUser", |
| 167 | query: "workspaces", |
| 168 | setupOwner: "self", |
| 169 | setupWorkspace: true, |
| 170 | expectError: false, |
| 171 | }, |
| 172 | { |
| 173 | name: "ValidWorkspacesQuery_CurrentUserMe", |
| 174 | query: "workspaces/owner:me", |
| 175 | setupOwner: "self", |
| 176 | setupWorkspace: true, |
| 177 | expectError: false, |
| 178 | }, |
| 179 | { |
| 180 | name: "ValidWorkspacesQuery_NoWorkspaces", |
| 181 | query: "workspaces", |
| 182 | setupOwner: "self", |
| 183 | setupWorkspace: false, |
| 184 | expectError: false, |
| 185 | }, |
| 186 | { |
| 187 | name: "ValidWorkspacesQuery_SpecificUser", |
| 188 | query: "workspaces/owner:otheruser", |
| 189 | setupOwner: "other", |
| 190 | setupWorkspace: true, |
| 191 | expectError: false, |
| 192 | }, |
| 193 | } |
| 194 | |
| 195 | for _, tt := range tests { |
| 196 | t.Run(tt.name, func(t *testing.T) { |
| 197 | t.Parallel() |
| 198 | |
| 199 | // Setup |
| 200 | client, store := coderdtest.NewWithDatabase(t, nil) |
| 201 | owner := coderdtest.CreateFirstUser(t, client) |
| 202 | |
| 203 | var workspaceOwnerID uuid.UUID |
| 204 | var workspaceClient *codersdk.Client |
| 205 | if tt.setupOwner == "self" { |
| 206 | workspaceOwnerID = owner.UserID |
| 207 | workspaceClient = client |
| 208 | } else { |
| 209 | var workspaceOwner codersdk.User |
| 210 | workspaceClient, workspaceOwner = coderdtest.CreateAnotherUserMutators(t, client, owner.OrganizationID, nil, func(r *codersdk.CreateUserRequestWithOrgs) { |
| 211 | r.Username = "otheruser" |
nothing calls this directly
no test coverage detected