@@ -310,9 +310,13 @@ func TestValidateFormType(t *testing.T) {
310
310
OptionType: %q,
311
311
FormType: %q,
312
312
}),
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
+ }
316
320
})
317
321
318
322
}
@@ -376,23 +380,24 @@ func ezconfig(paramName string, cfg formTypeCheck) (defaultValue string, tf stri
376
380
` , paramName , paramName , body .String ())
377
381
}
378
382
379
- func formTypeTest (t * testing.T , c formTypeTestCase ) {
383
+ func formTypeTest (t * testing.T , c formTypeTestCase ) bool {
380
384
t .Helper ()
381
385
const paramName = "test_param"
386
+ // probablyPassed is just a guess used for logging. It's not important.
387
+ probablyPassed := true
382
388
383
389
def , tf := ezconfig (paramName , c .config )
384
- t .Logf ("Terraform config:\n %s" , tf )
385
390
checkFn := func (state * terraform.State ) error {
386
391
require .Len (t , state .Modules , 1 )
387
392
require .Len (t , state .Modules [0 ].Resources , 1 )
388
393
389
394
key := strings .Join ([]string {"data" , "coder_parameter" , paramName }, "." )
390
395
param := state .Modules [0 ].Resources [key ]
391
396
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" )
396
401
397
402
return nil
398
403
}
@@ -411,4 +416,9 @@ func formTypeTest(t *testing.T, c formTypeTestCase) {
411
416
},
412
417
},
413
418
})
419
+
420
+ if ! probablyPassed {
421
+ t .Logf ("Terraform config:\n %s" , tf )
422
+ }
423
+ return probablyPassed
414
424
}
0 commit comments