(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestEnterpriseListTemplates(t *testing.T) { |
| 21 | t.Parallel() |
| 22 | |
| 23 | t.Run("MultiOrg", func(t *testing.T) { |
| 24 | t.Parallel() |
| 25 | |
| 26 | client, owner := coderdenttest.New(t, &coderdenttest.Options{ |
| 27 | Options: &coderdtest.Options{ |
| 28 | IncludeProvisionerDaemon: true, |
| 29 | }, |
| 30 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 31 | Features: license.Features{ |
| 32 | codersdk.FeatureMultipleOrganizations: 1, |
| 33 | codersdk.FeatureExternalProvisionerDaemons: 1, |
| 34 | }, |
| 35 | }, |
| 36 | }) |
| 37 | |
| 38 | // Template in the first organization |
| 39 | firstVersion := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil) |
| 40 | _ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, firstVersion.ID) |
| 41 | _ = coderdtest.CreateTemplate(t, client, owner.OrganizationID, firstVersion.ID) |
| 42 | |
| 43 | secondOrg := coderdenttest.CreateOrganization(t, client, coderdenttest.CreateOrganizationOptions{ |
| 44 | IncludeProvisionerDaemon: true, |
| 45 | }) |
| 46 | secondVersion := coderdtest.CreateTemplateVersion(t, client, secondOrg.ID, nil) |
| 47 | _ = coderdtest.CreateTemplate(t, client, secondOrg.ID, secondVersion.ID) |
| 48 | |
| 49 | // Create a site wide template admin |
| 50 | templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin()) |
| 51 | |
| 52 | inv, root := clitest.New(t, "templates", "list", "--output=json") |
| 53 | clitest.SetupConfig(t, templateAdmin, root) |
| 54 | |
| 55 | ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 56 | defer cancelFunc() |
| 57 | |
| 58 | out := bytes.NewBuffer(nil) |
| 59 | inv.Stdout = out |
| 60 | err := inv.WithContext(ctx).Run() |
| 61 | require.NoError(t, err) |
| 62 | |
| 63 | var templates []codersdk.Template |
| 64 | require.NoError(t, json.Unmarshal(out.Bytes(), &templates)) |
| 65 | require.Len(t, templates, 2) |
| 66 | }) |
| 67 | } |
nothing calls this directly
no test coverage detected