Skip to content

Commit fd17857

Browse files
authored
fix(cli): template pull tests: await template version job before exiting (#9430)
1 parent ed50aca commit fd17857

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

cli/templatepull_test.go

+20-8
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ func TestTemplatePull_NoName(t *testing.T) {
5353
func TestTemplatePull_Stdout(t *testing.T) {
5454
t.Parallel()
5555

56-
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
56+
client := coderdtest.New(t, &coderdtest.Options{
57+
IncludeProvisionerDaemon: true,
58+
})
5759
user := coderdtest.CreateFirstUser(t, client)
5860

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

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

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

94-
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
97+
client := coderdtest.New(t, &coderdtest.Options{
98+
IncludeProvisionerDaemon: true,
99+
})
95100
user := coderdtest.CreateFirstUser(t, client)
96101

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

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

115121
dir := t.TempDir()
116122

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

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

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

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

199-
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
208+
client := coderdtest.New(t, &coderdtest.Options{
209+
IncludeProvisionerDaemon: true,
210+
})
200211
user := coderdtest.CreateFirstUser(t, client)
201212

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

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

220232
dir := t.TempDir()
221233

0 commit comments

Comments
 (0)