Skip to content

feat: Add template pull cmd #2329

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
Jun 15, 2022
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
add some minor comments
  • Loading branch information
sreya committed Jun 14, 2022
commit c274b27a897f6fbec3f8a6c0354921640fb15d5b
10 changes: 5 additions & 5 deletions cli/templatepull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/coder/coder/coderd/coderdtest"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionersdk/proto"
"github.com/coder/coder/pty/ptytest"
)

func TestTemplatePull(t *testing.T) {
Expand All @@ -19,6 +18,7 @@ func TestTemplatePull(t *testing.T) {
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerD: true})
user := coderdtest.CreateFirstUser(t, client)

// Create an initial template bundle.
templateSource := &echo.Responses{
Parse: []*proto.Parse_Response{
{
Expand All @@ -36,6 +36,8 @@ func TestTemplatePull(t *testing.T) {
Provision: echo.ProvisionComplete,
}

// Create an updated template bundle. This will be used to ensure
// that templates are correctly returned in order from latest to oldest.
templateSource2 := &echo.Responses{
Parse: []*proto.Parse_Response{
{
Expand All @@ -60,20 +62,18 @@ func TestTemplatePull(t *testing.T) {
_ = coderdtest.AwaitTemplateVersionJob(t, client, version1.ID)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version1.ID)

// Update the template version so that we can assert that templates
// are being sorted correctly.
_ = coderdtest.UpdateTemplateVersion(t, client, user.OrganizationID, templateSource2, template.ID)

cmd, root := clitest.New(t, "templates", "pull", template.Name)
clitest.SetupConfig(t, client, root)

buf := &bytes.Buffer{}
pty := ptytest.New(t)
cmd.SetOut(buf)

err = cmd.Execute()
require.NoError(t, err)

err = pty.Close()
require.NoError(t, err)

require.True(t, bytes.Equal(expected, buf.Bytes()), "Bytes differ")
}