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 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
await template version job instead of ignoring log errors
  • Loading branch information
johnstcn committed Aug 31, 2023
commit 635534db239f13d5d063fc95f7f638fe1a027f1a
22 changes: 8 additions & 14 deletions cli/templatepull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/require"

"cdr.dev/slog/sloggers/slogtest"

"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/provisioner/echo"
Expand Down Expand Up @@ -55,10 +53,8 @@ func TestTemplatePull_NoName(t *testing.T) {
func TestTemplatePull_Stdout(t *testing.T) {
t.Parallel()

logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
Logger: &logger,
})
user := coderdtest.CreateFirstUser(t, client)

Expand All @@ -78,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 @@ -97,10 +94,8 @@ func TestTemplatePull_Stdout(t *testing.T) {
func TestTemplatePull_ToDir(t *testing.T) {
t.Parallel()

logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
Logger: &logger,
})
user := coderdtest.CreateFirstUser(t, client)

Expand All @@ -120,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 @@ -148,10 +144,8 @@ 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) {
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
Logger: &logger,
})
user := coderdtest.CreateFirstUser(t, client)

Expand All @@ -171,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 @@ -210,10 +205,8 @@ func TestTemplatePull_ToImplicit(t *testing.T) {
func TestTemplatePull_FolderConflict(t *testing.T) {
t.Parallel()

logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
Logger: &logger,
})
user := coderdtest.CreateFirstUser(t, client)

Expand All @@ -233,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