@@ -123,30 +123,36 @@ func TestTemplatePush(t *testing.T) {
123
123
ProvisionApply : echo .ProvisionComplete ,
124
124
})
125
125
126
- wantMessage := strings .Repeat ("a" , 73 )
127
-
128
- inv , root := clitest .New (t , "templates" , "push" , template .Name , "--directory" , source , "--test.provisioner" , string (database .ProvisionerTypeEcho ), "--name" , "example" , "--message" , wantMessage , "--yes" )
129
- clitest .SetupConfig (t , client , root )
130
- pty := ptytest .New (t ).Attach (inv )
131
-
132
- ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitMedium )
126
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
133
127
defer cancel ()
134
128
135
- inv = inv .WithContext (ctx )
136
- w := clitest .StartWithWaiter (t , inv )
129
+ for i , tt := range []struct {
130
+ wantMessage string
131
+ wantMatch string
132
+ }{
133
+ {wantMessage : strings .Repeat ("a" , 73 ), wantMatch : "Template message is longer than 72 characters" },
134
+ {wantMessage : "This is my title\n \n And this is my body." , wantMatch : "Template message contains newlines" },
135
+ } {
136
+ inv , root := clitest .New (t , "templates" , "push" , template .Name , "--directory" , source , "--test.provisioner" , string (database .ProvisionerTypeEcho ), "--name" , "example" , "--message" , tt .wantMessage , "--yes" )
137
+ clitest .SetupConfig (t , client , root )
138
+ pty := ptytest .New (t ).Attach (inv )
137
139
138
- pty .ExpectMatchContext (ctx , "Template message is longer than 72 characters" )
140
+ inv = inv .WithContext (ctx )
141
+ w := clitest .StartWithWaiter (t , inv )
139
142
140
- w . RequireSuccess ( )
143
+ pty . ExpectMatchContext ( ctx , tt . wantMatch )
141
144
142
- // Assert that the template version changed.
143
- templateVersions , err := client .TemplateVersionsByTemplate (ctx , codersdk.TemplateVersionsByTemplateRequest {
144
- TemplateID : template .ID ,
145
- })
146
- require .NoError (t , err )
147
- assert .Len (t , templateVersions , 2 )
148
- assert .NotEqual (t , template .ActiveVersionID , templateVersions [1 ].ID )
149
- require .Equal (t , wantMessage , templateVersions [1 ].Message )
145
+ w .RequireSuccess ()
146
+
147
+ // Assert that the template version changed.
148
+ templateVersions , err := client .TemplateVersionsByTemplate (ctx , codersdk.TemplateVersionsByTemplateRequest {
149
+ TemplateID : template .ID ,
150
+ })
151
+ require .NoError (t , err )
152
+ assert .Len (t , templateVersions , 2 + i )
153
+ assert .NotEqual (t , template .ActiveVersionID , templateVersions [1 + i ].ID )
154
+ require .Equal (t , tt .wantMessage , templateVersions [1 + i ].Message )
155
+ }
150
156
})
151
157
152
158
t .Run ("NoLockfile" , func (t * testing.T ) {
0 commit comments