Skip to content

fix(cli): template pull tests: await template version job before exiting #9430

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 2 commits into from
Aug 31, 2023
Merged
Changes from all commits
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
28 changes: 20 additions & 8 deletions cli/templatepull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ func TestTemplatePull_NoName(t *testing.T) {
func TestTemplatePull_Stdout(t *testing.T) {
t.Parallel()

client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)

// Create an initial template bundle.
Expand All @@ -72,7 +74,8 @@ func TestTemplatePull_Stdout(t *testing.T) {

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

inv, root := clitest.New(t, "templates", "pull", "--tar", template.Name)
clitest.SetupConfig(t, client, root)
Expand All @@ -91,7 +94,9 @@ func TestTemplatePull_Stdout(t *testing.T) {
func TestTemplatePull_ToDir(t *testing.T) {
t.Parallel()

client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)

// Create an initial template bundle.
Expand All @@ -110,7 +115,8 @@ func TestTemplatePull_ToDir(t *testing.T) {

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

dir := t.TempDir()

Expand Down Expand Up @@ -138,7 +144,9 @@ func TestTemplatePull_ToDir(t *testing.T) {
// and writes it to a directory with the name of the template if the path is not implicitly supplied.
// nolint: paralleltest
func TestTemplatePull_ToImplicit(t *testing.T) {
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)

// Create an initial template bundle.
Expand All @@ -157,7 +165,8 @@ func TestTemplatePull_ToImplicit(t *testing.T) {

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

// create a tempdir and change the working directory to it for the duration of the test (cannot run in parallel)
dir := t.TempDir()
Expand Down Expand Up @@ -196,7 +205,9 @@ func TestTemplatePull_ToImplicit(t *testing.T) {
func TestTemplatePull_FolderConflict(t *testing.T) {
t.Parallel()

client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
})
user := coderdtest.CreateFirstUser(t, client)

// Create an initial template bundle.
Expand All @@ -215,7 +226,8 @@ func TestTemplatePull_FolderConflict(t *testing.T) {

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

dir := t.TempDir()

Expand Down