MCPcopy Index your code
hub / github.com/coder/coder / TestMultipleOrganizationTemplates

Function TestMultipleOrganizationTemplates

enterprise/coderd/templates_test.go:2179–2228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2177}
2178
2179func TestMultipleOrganizationTemplates(t *testing.T) {
2180 t.Parallel()
2181
2182 dv := coderdtest.DeploymentValues(t)
2183 ownerClient, first := coderdenttest.New(t, &coderdenttest.Options{
2184 Options: &coderdtest.Options{
2185 // This only affects the first org.
2186 IncludeProvisionerDaemon: true,
2187 DeploymentValues: dv,
2188 },
2189 LicenseOptions: &coderdenttest.LicenseOptions{
2190 Features: license.Features{
2191 codersdk.FeatureExternalProvisionerDaemons: 1,
2192 codersdk.FeatureMultipleOrganizations: 1,
2193 },
2194 },
2195 })
2196
2197 templateAdmin, _ := coderdtest.CreateAnotherUser(t, ownerClient, first.OrganizationID, rbac.RoleTemplateAdmin())
2198
2199 second := coderdenttest.CreateOrganization(t, ownerClient, coderdenttest.CreateOrganizationOptions{
2200 IncludeProvisionerDaemon: true,
2201 })
2202
2203 third := coderdenttest.CreateOrganization(t, ownerClient, coderdenttest.CreateOrganizationOptions{
2204 IncludeProvisionerDaemon: true,
2205 })
2206
2207 t.Logf("First organization: %s", first.OrganizationID.String())
2208 t.Logf("Second organization: %s", second.ID.String())
2209 t.Logf("Third organization: %s", third.ID.String())
2210
2211 t.Log("Creating template version in second organization")
2212
2213 start := time.Now()
2214 version := coderdtest.CreateTemplateVersion(t, templateAdmin, second.ID, nil)
2215 coderdtest.AwaitTemplateVersionJobCompleted(t, ownerClient, version.ID)
2216 coderdtest.CreateTemplate(t, templateAdmin, second.ID, version.ID, func(request *codersdk.CreateTemplateRequest) {
2217 request.Name = "random"
2218 })
2219
2220 if time.Since(start) > time.Second*10 {
2221 // The test can sometimes pass because 'AwaitTemplateVersionJobCompleted'
2222 // allows 25s, and the provisioner will check every 30s if not awakened
2223 // from the pubsub. So there is a chance it will pass. If it takes longer
2224 // than 10s, then it's a problem. The provisioner is not getting clearance.
2225 t.Error("Creating template version in second organization took too long")
2226 t.FailNow()
2227 }
2228}
2229
2230func TestInvalidateTemplatePrebuilds(t *testing.T) {
2231 t.Parallel()

Callers

nothing calls this directly

Calls 13

DeploymentValuesFunction · 0.92
NewFunction · 0.92
CreateAnotherUserFunction · 0.92
RoleTemplateAdminFunction · 0.92
CreateOrganizationFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
LogMethod · 0.80
FailNowMethod · 0.80
LogfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected