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

Function TestTemplateCreate

enterprise/cli/templatecreate_test.go:20–202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestTemplateCreate(t *testing.T) {
21 t.Parallel()
22
23 t.Run("RequireActiveVersion", func(t *testing.T) {
24 t.Parallel()
25
26 client, user := coderdenttest.New(t, &coderdenttest.Options{
27 LicenseOptions: &coderdenttest.LicenseOptions{
28 Features: license.Features{
29 codersdk.FeatureAccessControl: 1,
30 },
31 },
32 Options: &coderdtest.Options{
33 IncludeProvisionerDaemon: true,
34 },
35 })
36 templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, user.OrganizationID, rbac.RoleTemplateAdmin())
37
38 source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
39 Parse: echo.ParseComplete,
40 ProvisionApply: echo.ApplyComplete,
41 })
42
43 inv, conf := newCLI(t, "templates",
44 "create", "new-template",
45 "--directory", source,
46 "--test.provisioner", string(database.ProvisionerTypeEcho),
47 "--require-active-version",
48 "-y",
49 )
50
51 clitest.SetupConfig(t, templateAdmin, conf)
52
53 err := inv.Run()
54 require.NoError(t, err)
55
56 ctx := testutil.Context(t, testutil.WaitMedium)
57 template, err := templateAdmin.TemplateByName(ctx, user.OrganizationID, "new-template")
58 require.NoError(t, err)
59 require.True(t, template.RequireActiveVersion)
60 })
61
62 t.Run("WorkspaceCleanup", func(t *testing.T) {
63 t.Parallel()
64
65 client, user := coderdenttest.New(t, &coderdenttest.Options{
66 LicenseOptions: &coderdenttest.LicenseOptions{
67 Features: license.Features{
68 codersdk.FeatureAdvancedTemplateScheduling: 1,
69 },
70 },
71 Options: &coderdtest.Options{
72 IncludeProvisionerDaemon: true,
73 },
74 })
75 templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, user.OrganizationID, rbac.RoleTemplateAdmin())
76
77 source := clitest.CreateTemplateVersionSource(t, &echo.Responses{

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
CreateAnotherUserFunction · 0.92
RoleTemplateAdminFunction · 0.92
SetupConfigFunction · 0.92
ContextFunction · 0.92
CreateOrganizationFunction · 0.92
CreatePermissionsFunction · 0.92
newCLIFunction · 0.85
RunMethod · 0.65
TemplateByNameMethod · 0.65

Tested by

no test coverage detected