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

Function TestChatACLValidation

coderd/exp_chats_acl_test.go:229–318  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

227}
228
229func 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 },

Callers

nothing calls this directly

Calls 13

ContextFunction · 0.92
CreateFirstUserFunction · 0.92
ChatRoleTypeAlias · 0.92
createChatForSharingFunction · 0.85
requireSDKErrorFunction · 0.85
UpdateChatACLMethod · 0.80
newChatClientFunction · 0.70
createChatModelConfigFunction · 0.70
NewMethod · 0.65
RunMethod · 0.65
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected