@@ -10,7 +10,6 @@ import (
10
10
"github.com/coder/coder/coderd/coderdtest"
11
11
"github.com/coder/coder/provisioner/echo"
12
12
"github.com/coder/coder/provisionersdk/proto"
13
- "github.com/coder/coder/pty/ptytest"
14
13
)
15
14
16
15
func TestTemplatePull (t * testing.T ) {
@@ -19,6 +18,7 @@ func TestTemplatePull(t *testing.T) {
19
18
client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerD : true })
20
19
user := coderdtest .CreateFirstUser (t , client )
21
20
21
+ // Create an initial template bundle.
22
22
templateSource := & echo.Responses {
23
23
Parse : []* proto.Parse_Response {
24
24
{
@@ -36,6 +36,8 @@ func TestTemplatePull(t *testing.T) {
36
36
Provision : echo .ProvisionComplete ,
37
37
}
38
38
39
+ // Create an updated template bundle. This will be used to ensure
40
+ // that templates are correctly returned in order from latest to oldest.
39
41
templateSource2 := & echo.Responses {
40
42
Parse : []* proto.Parse_Response {
41
43
{
@@ -60,20 +62,18 @@ func TestTemplatePull(t *testing.T) {
60
62
_ = coderdtest .AwaitTemplateVersionJob (t , client , version1 .ID )
61
63
template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version1 .ID )
62
64
65
+ // Update the template version so that we can assert that templates
66
+ // are being sorted correctly.
63
67
_ = coderdtest .UpdateTemplateVersion (t , client , user .OrganizationID , templateSource2 , template .ID )
64
68
65
69
cmd , root := clitest .New (t , "templates" , "pull" , template .Name )
66
70
clitest .SetupConfig (t , client , root )
67
71
68
72
buf := & bytes.Buffer {}
69
- pty := ptytest .New (t )
70
73
cmd .SetOut (buf )
71
74
72
75
err = cmd .Execute ()
73
76
require .NoError (t , err )
74
77
75
- err = pty .Close ()
76
- require .NoError (t , err )
77
-
78
78
require .True (t , bytes .Equal (expected , buf .Bytes ()), "Bytes differ" )
79
79
}
0 commit comments