mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
chore: include all templates in cli template list (#13841)
* chore: cli template list includes all templates Shows all accessible templates from all organizations
This commit is contained in:
@ -88,9 +88,6 @@ func TestTemplateList(t *testing.T) {
|
||||
client := coderdtest.New(t, &coderdtest.Options{})
|
||||
owner := coderdtest.CreateFirstUser(t, client)
|
||||
|
||||
org, err := client.Organization(context.Background(), owner.OrganizationID)
|
||||
require.NoError(t, err)
|
||||
|
||||
templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin())
|
||||
|
||||
inv, root := clitest.New(t, "templates", "list")
|
||||
@ -110,8 +107,42 @@ func TestTemplateList(t *testing.T) {
|
||||
|
||||
require.NoError(t, <-errC)
|
||||
|
||||
pty.ExpectMatch("No templates found in")
|
||||
pty.ExpectMatch(org.Name)
|
||||
pty.ExpectMatch("No templates found")
|
||||
pty.ExpectMatch("Create one:")
|
||||
})
|
||||
|
||||
t.Run("MultiOrg", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
owner := coderdtest.CreateFirstUser(t, client)
|
||||
|
||||
// Template in the first organization
|
||||
firstVersion := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil)
|
||||
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, firstVersion.ID)
|
||||
_ = coderdtest.CreateTemplate(t, client, owner.OrganizationID, firstVersion.ID)
|
||||
|
||||
secondOrg := coderdtest.CreateOrganization(t, client, coderdtest.CreateOrganizationOptions{
|
||||
IncludeProvisionerDaemon: true,
|
||||
})
|
||||
secondVersion := coderdtest.CreateTemplateVersion(t, client, secondOrg.ID, nil)
|
||||
_ = coderdtest.CreateTemplate(t, client, secondOrg.ID, secondVersion.ID)
|
||||
|
||||
// Create a site wide template admin
|
||||
templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin())
|
||||
|
||||
inv, root := clitest.New(t, "templates", "list", "--output=json")
|
||||
clitest.SetupConfig(t, templateAdmin, root)
|
||||
|
||||
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancelFunc()
|
||||
|
||||
out := bytes.NewBuffer(nil)
|
||||
inv.Stdout = out
|
||||
err := inv.WithContext(ctx).Run()
|
||||
require.NoError(t, err)
|
||||
|
||||
var templates []codersdk.Template
|
||||
require.NoError(t, json.Unmarshal(out.Bytes(), &templates))
|
||||
require.Len(t, templates, 2)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user