| 11 | ) |
| 12 | |
| 13 | func Test_Config(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | id := uuid.Must(uuid.NewRandom()) |
| 17 | |
| 18 | cases := []struct { |
| 19 | name string |
| 20 | config workspacebuild.Config |
| 21 | errContains string |
| 22 | }{ |
| 23 | { |
| 24 | name: "NoOrganizationID", |
| 25 | config: workspacebuild.Config{ |
| 26 | OrganizationID: uuid.Nil, |
| 27 | UserID: id.String(), |
| 28 | Request: codersdk.CreateWorkspaceRequest{ |
| 29 | TemplateID: id, |
| 30 | }, |
| 31 | NoWaitForAgents: true, |
| 32 | }, |
| 33 | errContains: "organization_id must be set", |
| 34 | }, |
| 35 | { |
| 36 | name: "NoUserID", |
| 37 | config: workspacebuild.Config{ |
| 38 | OrganizationID: id, |
| 39 | UserID: "", |
| 40 | Request: codersdk.CreateWorkspaceRequest{ |
| 41 | TemplateID: id, |
| 42 | }, |
| 43 | }, |
| 44 | errContains: "user_id must be set", |
| 45 | }, |
| 46 | { |
| 47 | name: "UserIDNotUUID", |
| 48 | config: workspacebuild.Config{ |
| 49 | OrganizationID: id, |
| 50 | UserID: "blah", |
| 51 | Request: codersdk.CreateWorkspaceRequest{ |
| 52 | TemplateID: id, |
| 53 | }, |
| 54 | }, |
| 55 | errContains: "user_id must be \"me\" or a valid UUID", |
| 56 | }, |
| 57 | { |
| 58 | name: "NoTemplateID", |
| 59 | config: workspacebuild.Config{ |
| 60 | OrganizationID: id, |
| 61 | UserID: id.String(), |
| 62 | Request: codersdk.CreateWorkspaceRequest{ |
| 63 | TemplateID: uuid.Nil, |
| 64 | }, |
| 65 | }, |
| 66 | errContains: "request.template_id must be set", |
| 67 | }, |
| 68 | { |
| 69 | name: "UserMe", |
| 70 | config: workspacebuild.Config{ |