@@ -157,7 +157,7 @@ func TestWorkspacePreset(t *testing.T) {
157157 expiration_policy {}
158158 }
159159 }` ,
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.` ),
161161 },
162162 {
163163 Name : "Prebuilds is set with a expiration_policy field with its required fields" ,
@@ -186,6 +186,50 @@ func TestWorkspacePreset(t *testing.T) {
186186 return nil
187187 },
188188 },
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+ },
216+ {
217+ Name : "Prebuilds block with expiration_policy.ttl set to 30 minutes (below 1 hour limit)" ,
218+ Config : `
219+ data "coder_workspace_preset" "preset_1" {
220+ name = "preset_1"
221+ parameters = {
222+ "region" = "us-east1-a"
223+ }
224+ prebuilds {
225+ instances = 1
226+ expiration_policy {
227+ ttl = 1800
228+ }
229+ }
230+ }` ,
231+ ExpectError : regexp .MustCompile (`"prebuilds.0.expiration_policy.0.ttl" must be 0 or between 3600 and 31536000, got 1800` ),
232+ },
189233 {
190234 Name : "Prebuilds block with expiration_policy.ttl set to 2 years (exceeds 1 year limit)" ,
191235 Config : `
@@ -201,7 +245,7 @@ func TestWorkspacePreset(t *testing.T) {
201245 }
202246 }
203247 }` ,
204- ExpectError : regexp .MustCompile (`expected prebuilds.0.expiration_policy.0.ttl to be in the range \(0 - 31536000\) , got 63072000` ),
248+ ExpectError : regexp .MustCompile (`" prebuilds.0.expiration_policy.0.ttl" must be 0 or between 3600 and 31536000, got 63072000` ),
205249 },
206250 {
207251 Name : "Prebuilds is set with a expiration_policy field with its required fields and an unexpected argument" ,
0 commit comments