@@ -157,7 +157,7 @@ func TestWorkspacePreset(t *testing.T) {
157
157
expiration_policy {}
158
158
}
159
159
}` ,
160
- ExpectError : regexp .MustCompile (" The argument \ " ttl\ " is required, but no definition was found." ),
160
+ ExpectError : regexp .MustCompile (` The argument "ttl" is required, but no definition was found.` ),
161
161
},
162
162
{
163
163
Name : "Prebuilds is set with a expiration_policy field with its required fields" ,
@@ -186,6 +186,33 @@ func TestWorkspacePreset(t *testing.T) {
186
186
return nil
187
187
},
188
188
},
189
+ {
190
+ Name : "Prebuilds block with expiration_policy.ttl set to 0 seconds (disables expiration)" ,
191
+ Config : `
192
+ data "coder_workspace_preset" "preset_1" {
193
+ name = "preset_1"
194
+ parameters = {
195
+ "region" = "us-east1-a"
196
+ }
197
+ prebuilds {
198
+ instances = 1
199
+ expiration_policy {
200
+ ttl = 0
201
+ }
202
+ }
203
+ }` ,
204
+ ExpectError : nil ,
205
+ Check : func (state * terraform.State ) error {
206
+ require .Len (t , state .Modules , 1 )
207
+ require .Len (t , state .Modules [0 ].Resources , 1 )
208
+ resource := state .Modules [0 ].Resources ["data.coder_workspace_preset.preset_1" ]
209
+ require .NotNil (t , resource )
210
+ attrs := resource .Primary .Attributes
211
+ require .Equal (t , attrs ["name" ], "preset_1" )
212
+ require .Equal (t , attrs ["prebuilds.0.expiration_policy.0.ttl" ], "0" )
213
+ return nil
214
+ },
215
+ },
189
216
{
190
217
Name : "Prebuilds block with expiration_policy.ttl set to 30 minutes (below 1 hour limit)" ,
191
218
Config : `
@@ -201,7 +228,7 @@ func TestWorkspacePreset(t *testing.T) {
201
228
}
202
229
}
203
230
}` ,
204
- ExpectError : regexp .MustCompile (`expected prebuilds.0.expiration_policy.0.ttl to be in the range \( 3600 - 31536000\) , got 1800` ),
231
+ ExpectError : regexp .MustCompile (`" prebuilds.0.expiration_policy.0.ttl" must be 0 or between 3600 and 31536000, got 1800` ),
205
232
},
206
233
{
207
234
Name : "Prebuilds block with expiration_policy.ttl set to 2 years (exceeds 1 year limit)" ,
@@ -218,7 +245,7 @@ func TestWorkspacePreset(t *testing.T) {
218
245
}
219
246
}
220
247
}` ,
221
- ExpectError : regexp .MustCompile (`expected prebuilds.0.expiration_policy.0.ttl to be in the range \( 3600 - 31536000\) , got 63072000` ),
248
+ ExpectError : regexp .MustCompile (`" prebuilds.0.expiration_policy.0.ttl" must be 0 or between 3600 and 31536000, got 63072000` ),
222
249
},
223
250
{
224
251
Name : "Prebuilds is set with a expiration_policy field with its required fields and an unexpected argument" ,
0 commit comments