@@ -114,39 +114,7 @@ func TestCreate(t *testing.T) {
114
114
115
115
defaultValue := "something"
116
116
version := coderdtest .CreateTemplateVersion (t ,client ,user .OrganizationID ,& echo.Responses {
117
- Parse : []* proto.Parse_Response {{
118
- Type :& proto.Parse_Response_Complete {
119
- Complete :& proto.Parse_Complete {
120
- ParameterSchemas : []* proto.ParameterSchema {
121
- {
122
- AllowOverrideSource :true ,
123
- Name :"region" ,
124
- Description :"description 1" ,
125
- DefaultSource :& proto.ParameterSource {
126
- Scheme :proto .ParameterSource_DATA ,
127
- Value :defaultValue ,
128
- },
129
- DefaultDestination :& proto.ParameterDestination {
130
- Scheme :proto .ParameterDestination_PROVISIONER_VARIABLE ,
131
- },
132
- },
133
- {
134
- AllowOverrideSource :true ,
135
- Name :"username" ,
136
- Description :"description 2" ,
137
- DefaultSource :& proto.ParameterSource {
138
- Scheme :proto .ParameterSource_DATA ,
139
- // No default value
140
- Value :"" ,
141
- },
142
- DefaultDestination :& proto.ParameterDestination {
143
- Scheme :proto .ParameterDestination_PROVISIONER_VARIABLE ,
144
- },
145
- },
146
- },
147
- },
148
- },
149
- }},
117
+ Parse :createTestParseResponseWithDefault (defaultValue ),
150
118
Provision :echo .ProvisionComplete ,
151
119
ProvisionDryRun :echo .ProvisionComplete ,
152
120
})
@@ -187,39 +155,7 @@ func TestCreate(t *testing.T) {
187
155
188
156
defaultValue := "something"
189
157
version := coderdtest .CreateTemplateVersion (t ,client ,user .OrganizationID ,& echo.Responses {
190
- Parse : []* proto.Parse_Response {{
191
- Type :& proto.Parse_Response_Complete {
192
- Complete :& proto.Parse_Complete {
193
- ParameterSchemas : []* proto.ParameterSchema {
194
- {
195
- AllowOverrideSource :true ,
196
- Name :"region" ,
197
- Description :"description 1" ,
198
- DefaultSource :& proto.ParameterSource {
199
- Scheme :proto .ParameterSource_DATA ,
200
- Value :defaultValue ,
201
- },
202
- DefaultDestination :& proto.ParameterDestination {
203
- Scheme :proto .ParameterDestination_PROVISIONER_VARIABLE ,
204
- },
205
- },
206
- {
207
- AllowOverrideSource :true ,
208
- Name :"username" ,
209
- Description :"description 2" ,
210
- DefaultSource :& proto.ParameterSource {
211
- Scheme :proto .ParameterSource_DATA ,
212
- // No default value
213
- Value :"" ,
214
- },
215
- DefaultDestination :& proto.ParameterDestination {
216
- Scheme :proto .ParameterDestination_PROVISIONER_VARIABLE ,
217
- },
218
- },
219
- },
220
- },
221
- },
222
- }},
158
+ Parse :createTestParseResponseWithDefault (defaultValue ),
223
159
Provision :echo .ProvisionComplete ,
224
160
ProvisionDryRun :echo .ProvisionComplete ,
225
161
})
@@ -257,25 +193,9 @@ func TestCreate(t *testing.T) {
257
193
client := coderdtest .New (t ,& coderdtest.Options {IncludeProvisionerD :true })
258
194
user := coderdtest .CreateFirstUser (t ,client )
259
195
196
+ defaultValue := "something"
260
197
version := coderdtest .CreateTemplateVersion (t ,client ,user .OrganizationID ,& echo.Responses {
261
- Parse : []* proto.Parse_Response {{
262
- Type :& proto.Parse_Response_Complete {
263
- Complete :& proto.Parse_Complete {
264
- ParameterSchemas : []* proto.ParameterSchema {{
265
- AllowOverrideSource :true ,
266
- Name :"region" ,
267
- Description :"description" ,
268
- DefaultSource :& proto.ParameterSource {
269
- Scheme :proto .ParameterSource_DATA ,
270
- Value :"something" ,
271
- },
272
- DefaultDestination :& proto.ParameterDestination {
273
- Scheme :proto .ParameterDestination_PROVISIONER_VARIABLE ,
274
- },
275
- }},
276
- },
277
- },
278
- }},
198
+ Parse :createTestParseResponseWithDefault (defaultValue ),
279
199
Provision :echo .ProvisionComplete ,
280
200
ProvisionDryRun :echo .ProvisionComplete ,
281
201
})
@@ -297,3 +217,39 @@ func TestCreate(t *testing.T) {
297
217
<- doneChan
298
218
})
299
219
}
220
+
221
+ func createTestParseResponseWithDefault (defaultValue string ) []* proto.Parse_Response {
222
+ return []* proto.Parse_Response {{
223
+ Type :& proto.Parse_Response_Complete {
224
+ Complete :& proto.Parse_Complete {
225
+ ParameterSchemas : []* proto.ParameterSchema {
226
+ {
227
+ AllowOverrideSource :true ,
228
+ Name :"region" ,
229
+ Description :"description 1" ,
230
+ DefaultSource :& proto.ParameterSource {
231
+ Scheme :proto .ParameterSource_DATA ,
232
+ Value :defaultValue ,
233
+ },
234
+ DefaultDestination :& proto.ParameterDestination {
235
+ Scheme :proto .ParameterDestination_PROVISIONER_VARIABLE ,
236
+ },
237
+ },
238
+ {
239
+ AllowOverrideSource :true ,
240
+ Name :"username" ,
241
+ Description :"description 2" ,
242
+ DefaultSource :& proto.ParameterSource {
243
+ Scheme :proto .ParameterSource_DATA ,
244
+ // No default value
245
+ Value :"" ,
246
+ },
247
+ DefaultDestination :& proto.ParameterDestination {
248
+ Scheme :proto .ParameterDestination_PROVISIONER_VARIABLE ,
249
+ },
250
+ },
251
+ },
252
+ },
253
+ },
254
+ }}
255
+ }