66 "fmt"
77 "os"
88 "reflect"
9- "regexp"
109 "sort"
1110 "strings"
1211 "testing"
@@ -30,7 +29,18 @@ func init() {
3029
3130func TestParallelTest (t * testing.T ) {
3231 mt := new (mockT )
33- ParallelTest (mt , TestCase {})
32+
33+ // the test will error because the binary driver is unconfigured
34+ func () {
35+ defer func () {
36+ if r := recover (); r != nil {
37+ if ! strings .HasPrefix (r .(string ), "mockT" ) {
38+ panic (r )
39+ }
40+ }
41+ }()
42+ ParallelTest (mt , TestCase {IsUnitTest : true })
43+ }()
3444
3545 if ! mt .ParallelCalled {
3646 t .Fatal ("Parallel() not called" )
@@ -43,21 +53,27 @@ func TestTest_factoryError(t *testing.T) {
4353 factory := func () (* schema.Provider , error ) {
4454 return nil , resourceFactoryError
4555 }
46-
4756 mt := new (mockT )
48- Test (mt , TestCase {
49- ProviderFactories : map [string ]func () (* schema.Provider , error ){
50- "test" : factory ,
51- },
52- Steps : []TestStep {
53- {
54- ExpectError : regexp .MustCompile ("resource factory error" ),
57+
58+ func () {
59+ defer func () {
60+ if r := recover (); r != nil {
61+ if ! strings .HasPrefix (r .(string ), "mockT" ) {
62+ panic (r )
63+ }
64+ }
65+ }()
66+ Test (mt , TestCase {
67+ ProviderFactories : map [string ]func () (* schema.Provider , error ){
68+ "test" : factory ,
5569 },
56- },
57- })
70+ IsUnitTest : true ,
71+ })
72+ }()
5873
59- if ! mt .failed () {
60- t .Fatal ("test should've failed" )
74+ fatalStr := fmt .Sprint (mt .FatalArgs )
75+ if ! strings .Contains (fatalStr , resourceFactoryError .Error ()) {
76+ t .Fatalf ("test should've failed with %s, failed with %s" , resourceFactoryError , fatalStr )
6177 }
6278}
6379
@@ -161,6 +177,8 @@ func (t *mockT) Fatal(args ...interface{}) {
161177 t .FatalCalled = true
162178 t .FatalArgs = args
163179 t .f = true
180+
181+ panic ("mockT.Fatal" )
164182}
165183
166184func (t * mockT ) Parallel () {
0 commit comments