Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add unit test to verify creation of templates in multiple orgs
  • Loading branch information
Emyrk committed Jul 11, 2024
commit 63bade645b39581de1efbc5759ee2d97e62fc77c
34 changes: 34 additions & 0 deletions enterprise/coderd/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1829,3 +1829,37 @@ func TestTemplateAccess(t *testing.T) {
}
})
}

func TestMultipleOrganizationTemplates(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would always fail prior to this change.

t.Parallel()

ownerClient, first := coderdenttest.New(t, &coderdenttest.Options{
Options: &coderdtest.Options{
// This only affects the first org.
IncludeProvisionerDaemon: true,
},
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureExternalProvisionerDaemons: 1,
},
},
})

templateAdmin, _ := coderdtest.CreateAnotherUser(t, ownerClient, first.OrganizationID, rbac.RoleTemplateAdmin())

second := coderdtest.CreateOrganization(t, ownerClient, coderdtest.CreateOrganizationOptions{
IncludeProvisionerDaemon: true,
})

third := coderdtest.CreateOrganization(t, ownerClient, coderdtest.CreateOrganizationOptions{
IncludeProvisionerDaemon: true,
})

var _, _ = third, templateAdmin

version := coderdtest.CreateTemplateVersion(t, templateAdmin, second.ID, nil)
coderdtest.AwaitTemplateVersionJobCompleted(t, ownerClient, version.ID)
coderdtest.CreateTemplate(t, templateAdmin, second.ID, version.ID, func(request *codersdk.CreateTemplateRequest) {
request.Name = "random"
})
}