Skip to content

feat(cli): add --create flag to templates push #8454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 13, 2023
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
Prev Previous commit
Next Next commit
Unit test
  • Loading branch information
mtojek committed Jul 12, 2023
commit 9401f385ea3203a981d934ae36bfe9dd979be096
42 changes: 42 additions & 0 deletions cli/templatepush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,48 @@ func TestTemplatePush(t *testing.T) {
require.Equal(t, "second_variable", templateVariables[1].Name)
require.Equal(t, "foobar", templateVariables[1].Value)
})

t.Run("CreateTemplate", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
user := coderdtest.CreateFirstUser(t, client)
source := clitest.CreateTemplateVersionSource(t, &echo.Responses{
Parse: echo.ParseComplete,
ProvisionApply: provisionCompleteWithAgent,
})

const templateName = "my-template"
args := []string{
"templates",
"push",
templateName,
"--directory", source,
"--test.provisioner", string(database.ProvisionerTypeEcho),
"--create",
}
inv, root := clitest.New(t, args...)
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t).Attach(inv)

waiter := clitest.StartWithWaiter(t, inv)

matches := []struct {
match string
write string
}{
{match: "Upload", write: "yes"},
}
for _, m := range matches {
pty.ExpectMatch(m.match)
pty.WriteLine(m.write)
}

waiter.RequireSuccess()

template, err := client.TemplateByName(context.Background(), user.OrganizationID, templateName)
require.NoError(t, err)
require.Equal(t, templateName, template.Name)
})
})
}

Expand Down