(t *testing.T)
| 227 | } |
| 228 | |
| 229 | func TestChatACLValidation(t *testing.T) { |
| 230 | t.Parallel() |
| 231 | |
| 232 | ctx := testutil.Context(t, testutil.WaitLong) |
| 233 | client := newChatClient(t) |
| 234 | firstUser := coderdtest.CreateFirstUser(t, client.Client) |
| 235 | _ = createChatModelConfig(t, client) |
| 236 | chat := createChatForSharing(ctx, t, client, firstUser.OrganizationID, "validation chat") |
| 237 | missingUserID := uuid.New() |
| 238 | missingGroupID := uuid.New() |
| 239 | |
| 240 | tests := []struct { |
| 241 | name string |
| 242 | req codersdk.UpdateChatACL |
| 243 | wantValidation codersdk.ValidationError |
| 244 | }{ |
| 245 | { |
| 246 | name: "InvalidRole", |
| 247 | req: codersdk.UpdateChatACL{ |
| 248 | UserRoles: map[string]codersdk.ChatRole{ |
| 249 | uuid.NewString(): codersdk.ChatRole("write"), |
| 250 | }, |
| 251 | }, |
| 252 | wantValidation: codersdk.ValidationError{ |
| 253 | Field: "user_roles", |
| 254 | Detail: `role "write" is not a valid chat role`, |
| 255 | }, |
| 256 | }, |
| 257 | { |
| 258 | name: "InvalidUserUUID", |
| 259 | req: codersdk.UpdateChatACL{ |
| 260 | UserRoles: map[string]codersdk.ChatRole{ |
| 261 | "not-a-uuid": codersdk.ChatRoleRead, |
| 262 | }, |
| 263 | }, |
| 264 | wantValidation: codersdk.ValidationError{ |
| 265 | Field: "user_roles", |
| 266 | Detail: "not-a-uuid is not a valid UUID.", |
| 267 | }, |
| 268 | }, |
| 269 | { |
| 270 | name: "InvalidGroupUUID", |
| 271 | req: codersdk.UpdateChatACL{ |
| 272 | GroupRoles: map[string]codersdk.ChatRole{ |
| 273 | "not-a-uuid": codersdk.ChatRoleRead, |
| 274 | }, |
| 275 | }, |
| 276 | wantValidation: codersdk.ValidationError{ |
| 277 | Field: "group_roles", |
| 278 | Detail: "not-a-uuid is not a valid UUID.", |
| 279 | }, |
| 280 | }, |
| 281 | { |
| 282 | name: "MissingUser", |
| 283 | req: codersdk.UpdateChatACL{ |
| 284 | UserRoles: map[string]codersdk.ChatRole{ |
| 285 | missingUserID.String(): codersdk.ChatRoleRead, |
| 286 | }, |
nothing calls this directly
no test coverage detected