@@ -246,3 +246,61 @@ def test_enum_invalid_value_has_clean_error(tmp_path):
246246 renderer .prompt_for_missing_vars ("{{@ environment @}}" , {"environment" : "qa" })
247247
248248 assert str (excinfo .value ) == "Variable 'environment' must be one of: dev, staging, prod. Got: qa."
249+
250+
251+ def test_regex_violation_raises_template_variable_error (tmp_path ):
252+ """Regex pattern mismatch raises TemplateVariableError, not plain ValueError."""
253+ config_variables = [
254+ {"slug" : {"type" : "string" , "pattern" : "^[a-z0-9-]+$" }}
255+ ]
256+ renderer = TemplateRenderer (
257+ config_variables ,
258+ str (tmp_path / "input.json" ),
259+ non_interactive = True ,
260+ )
261+
262+ with pytest .raises (TemplateVariableError ) as excinfo :
263+ renderer .prompt_for_missing_vars ("{{@ slug @}}" , {"slug" : "Invalid Slug!" })
264+
265+ msg = str (excinfo .value )
266+ assert "slug" in msg
267+ assert "^[a-z0-9-]+$" in msg
268+ assert "Invalid Slug!" in msg
269+
270+
271+ def test_min_violation_raises_template_variable_error (tmp_path ):
272+ """Value below min raises TemplateVariableError, not plain ValueError."""
273+ config_variables = [
274+ {"retries" : {"type" : "integer" , "min" : 1 , "max" : 10 }}
275+ ]
276+ renderer = TemplateRenderer (
277+ config_variables ,
278+ str (tmp_path / "input.json" ),
279+ non_interactive = True ,
280+ )
281+
282+ with pytest .raises (TemplateVariableError ) as excinfo :
283+ renderer .prompt_for_missing_vars ("{{@ retries @}}" , {"retries" : 0 })
284+
285+ msg = str (excinfo .value )
286+ assert "retries" in msg
287+ assert ">= 1" in msg
288+
289+
290+ def test_max_violation_raises_template_variable_error (tmp_path ):
291+ """Value above max raises TemplateVariableError, not plain ValueError."""
292+ config_variables = [
293+ {"retries" : {"type" : "integer" , "min" : 1 , "max" : 10 }}
294+ ]
295+ renderer = TemplateRenderer (
296+ config_variables ,
297+ str (tmp_path / "input.json" ),
298+ non_interactive = True ,
299+ )
300+
301+ with pytest .raises (TemplateVariableError ) as excinfo :
302+ renderer .prompt_for_missing_vars ("{{@ retries @}}" , {"retries" : 99 })
303+
304+ msg = str (excinfo .value )
305+ assert "retries" in msg
306+ assert "<= 10" in msg
0 commit comments