| 329 | } |
| 330 | |
| 331 | func CreateOrganization(t *testing.T, client *codersdk.Client, opts CreateOrganizationOptions, mutators ...func(*codersdk.CreateOrganizationRequest)) codersdk.Organization { |
| 332 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 333 | req := codersdk.CreateOrganizationRequest{ |
| 334 | Name: strings.ToLower(namesgenerator.UniqueNameWith("-")), |
| 335 | DisplayName: namesgenerator.UniqueName(), |
| 336 | Description: namesgenerator.UniqueName(), |
| 337 | Icon: "", |
| 338 | } |
| 339 | for _, mutator := range mutators { |
| 340 | mutator(&req) |
| 341 | } |
| 342 | |
| 343 | org, err := client.CreateOrganization(ctx, req) |
| 344 | require.NoError(t, err) |
| 345 | |
| 346 | if opts.IncludeProvisionerDaemon { |
| 347 | closer := NewExternalProvisionerDaemon(t, client, org.ID, map[string]string{}) |
| 348 | t.Cleanup(func() { |
| 349 | _ = closer.Close() |
| 350 | }) |
| 351 | } |
| 352 | |
| 353 | return org |
| 354 | } |
| 355 | |
| 356 | // NewExternalProvisionerDaemon runs an external provisioner daemon in a |
| 357 | // goroutine and returns a closer to stop it. The echo provisioner is used |