@@ -310,9 +310,13 @@ func TestValidateFormType(t *testing.T) {
310310 OptionType: %q,
311311 FormType: %q,
312312 }),
313- ` , "<expected_form_type>" , check .options , check .optionType , check .formType )
314- t .Logf ("To construct this test case:\n %s" , tcText )
315- formTypeTest (t , fc )
313+ //` , "<expected_form_type>" , check .options , check .optionType , check .formType )
314+ var _ = tcText
315+
316+ probablyPassed := formTypeTest (t , fc )
317+ if ! probablyPassed {
318+ t .Logf ("To construct this test case:\n %s" , tcText )
319+ }
316320 })
317321
318322 }
@@ -376,23 +380,24 @@ func ezconfig(paramName string, cfg formTypeCheck) (defaultValue string, tf stri
376380 ` , paramName , paramName , body .String ())
377381}
378382
379- func formTypeTest (t * testing.T , c formTypeTestCase ) {
383+ func formTypeTest (t * testing.T , c formTypeTestCase ) bool {
380384 t .Helper ()
381385 const paramName = "test_param"
386+ // probablyPassed is just a guess used for logging. It's not important.
387+ probablyPassed := true
382388
383389 def , tf := ezconfig (paramName , c .config )
384- t .Logf ("Terraform config:\n %s" , tf )
385390 checkFn := func (state * terraform.State ) error {
386391 require .Len (t , state .Modules , 1 )
387392 require .Len (t , state .Modules [0 ].Resources , 1 )
388393
389394 key := strings .Join ([]string {"data" , "coder_parameter" , paramName }, "." )
390395 param := state .Modules [0 ].Resources [key ]
391396
392- assert .Equal (t , def , param .Primary .Attributes ["default" ], "default value" )
393- assert .Equal (t , string (c .assert .FormType ), param .Primary .Attributes ["form_type" ], "form_type" )
394- assert .Equal (t , string (c .assert .Type ), param .Primary .Attributes ["type" ], "type" )
395- assert .JSONEq (t , string (c .assert .Styling ), param .Primary .Attributes ["styling" ], "styling" )
397+ probablyPassed = probablyPassed && assert .Equal (t , def , param .Primary .Attributes ["default" ], "default value" )
398+ probablyPassed = probablyPassed && assert .Equal (t , string (c .assert .FormType ), param .Primary .Attributes ["form_type" ], "form_type" )
399+ probablyPassed = probablyPassed && assert .Equal (t , string (c .assert .Type ), param .Primary .Attributes ["type" ], "type" )
400+ probablyPassed = probablyPassed && assert .JSONEq (t , string (c .assert .Styling ), param .Primary .Attributes ["styling" ], "styling" )
396401
397402 return nil
398403 }
@@ -411,4 +416,9 @@ func formTypeTest(t *testing.T, c formTypeTestCase) {
411416 },
412417 },
413418 })
419+
420+ if ! probablyPassed {
421+ t .Logf ("Terraform config:\n %s" , tf )
422+ }
423+ return probablyPassed
414424}
0 commit comments