@@ -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 )
126
+ for i , tt := range []struct {
127
+ wantMessage string
128
+ wantMatch string
129
+ }{
130
+ {wantMessage : strings .Repeat ("a" , 73 ), wantMatch : "Template message is longer than 72 characters" },
131
+ {wantMessage : "This is my title\n \n And this is my body." , wantMatch : "Template message contains newlines" },
132
+ } {
133
+ inv , root := clitest .New (t , "templates" , "push" , template .Name , "--directory" , source , "--test.provisioner" , string (database .ProvisionerTypeEcho ), "--name" , "example" , "--message" , tt .wantMessage , "--yes" )
134
+ clitest .SetupConfig (t , client , root )
135
+ pty := ptytest .New (t ).Attach (inv )
131
136
132
- ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitMedium )
133
- defer cancel ()
137
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitMedium )
138
+ defer cancel ()
134
139
135
- inv = inv .WithContext (ctx )
136
- w := clitest .StartWithWaiter (t , inv )
140
+ inv = inv .WithContext (ctx )
141
+ w := clitest .StartWithWaiter (t , inv )
137
142
138
- pty .ExpectMatchContext (ctx , "Template message is longer than 72 characters" )
143
+ pty .ExpectMatchContext (ctx , tt . wantMatch )
139
144
140
- w .RequireSuccess ()
145
+ w .RequireSuccess ()
141
146
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 )
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