Skip to content

Commit 57f4855

Browse files
committed
simulate exit of mockT.Fatal with panic/recover
remove returns after t.Fatal
1 parent 8f1c991 commit 57f4855

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

helper/resource/testing.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ func Test(t TestT, c TestCase) {
537537
// We require verbose mode so that the user knows what is going on.
538538
if !testing.Verbose() && !c.IsUnitTest {
539539
t.Fatal("Acceptance tests must be run with the -v flag on tests")
540-
return
541540
}
542541

543542
// Run the PreCheck if we have it

helper/resource/testing_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"os"
88
"reflect"
9-
"regexp"
109
"sort"
1110
"strings"
1211
"testing"
@@ -43,18 +42,19 @@ func TestTest_factoryError(t *testing.T) {
4342
factory := func() (*schema.Provider, error) {
4443
return nil, resourceFactoryError
4544
}
46-
4745
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"),
46+
47+
func() {
48+
defer func() {
49+
recover()
50+
}()
51+
Test(mt, TestCase{
52+
ProviderFactories: map[string]func() (*schema.Provider, error){
53+
"test": factory,
5554
},
56-
},
57-
})
55+
IsUnitTest: true,
56+
})
57+
}()
5858

5959
if !mt.failed() {
6060
t.Fatal("test should've failed")
@@ -161,6 +161,8 @@ func (t *mockT) Fatal(args ...interface{}) {
161161
t.FatalCalled = true
162162
t.FatalArgs = args
163163
t.f = true
164+
165+
panic("mockT.Fatal")
164166
}
165167

166168
func (t *mockT) Parallel() {

0 commit comments

Comments
 (0)