Skip to content

Commit 36b802f

Browse files
committed
wip
1 parent a19f315 commit 36b802f

File tree

5 files changed

+9
-49
lines changed

5 files changed

+9
-49
lines changed

helper/logging/logging.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"syscall"
1313

1414
"github.com/hashicorp/logutils"
15-
"github.com/mitchellh/go-testing-interface"
15+
"github.com/hashicorp/terraform-plugin-testing/internal/testingiface"
1616
)
1717

1818
// These are the environmental variables that determine if we log, and if
@@ -33,7 +33,7 @@ var ValidLevels = []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"}
3333
// logging controlled by Terraform itself and managed with the TF_ACC_LOG_PATH
3434
// environment variable. Calls to tflog.* will have their output managed by the
3535
// tfsdklog sink.
36-
func LogOutput(t testing.T) (logOutput io.Writer, err error) {
36+
func LogOutput(t testingiface.T) (logOutput io.Writer, err error) {
3737
logOutput = io.Discard
3838

3939
logLevel := LogLevel()
@@ -91,7 +91,7 @@ func LogOutput(t testing.T) (logOutput io.Writer, err error) {
9191
// SetOutput checks for a log destination with LogOutput, and calls
9292
// log.SetOutput with the result. If LogOutput returns nil, SetOutput uses
9393
// io.Discard. Any error from LogOutout is fatal.
94-
func SetOutput(t testing.T) {
94+
func SetOutput(t testingiface.T) {
9595
out, err := LogOutput(t)
9696
if err != nil {
9797
log.Fatal(err)

helper/resource/plan_checks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"errors"
99

1010
tfjson "github.com/hashicorp/terraform-json"
11+
"github.com/hashicorp/terraform-plugin-testing/internal/testingiface"
1112
"github.com/hashicorp/terraform-plugin-testing/plancheck"
12-
"github.com/mitchellh/go-testing-interface"
1313
)
1414

15-
func runPlanChecks(ctx context.Context, t testing.T, plan *tfjson.Plan, planChecks []plancheck.PlanCheck) error {
15+
func runPlanChecks(ctx context.Context, t testingiface.T, plan *tfjson.Plan, planChecks []plancheck.PlanCheck) error {
1616
t.Helper()
1717

1818
var result []error

helper/resource/plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import (
1717
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
1818
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1919
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
20-
"github.com/mitchellh/go-testing-interface"
2120

2221
"github.com/hashicorp/terraform-plugin-testing/internal/logging"
2322
"github.com/hashicorp/terraform-plugin-testing/internal/plugintest"
23+
"github.com/hashicorp/terraform-plugin-testing/internal/testingiface"
2424
)
2525

2626
// protov5ProviderFactory is a function which is called to start a protocol
@@ -113,7 +113,7 @@ type providerFactories struct {
113113
protov6 protov6ProviderFactories
114114
}
115115

116-
func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *plugintest.WorkingDir, factories *providerFactories) error {
116+
func runProviderCommand(ctx context.Context, t testingiface.T, f func() error, wd *plugintest.WorkingDir, factories *providerFactories) error {
117117
// don't point to this as a test failure location
118118
// point to whatever called it
119119
t.Helper()

helper/resource/state_checks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88
"errors"
99

1010
tfjson "github.com/hashicorp/terraform-json"
11-
"github.com/mitchellh/go-testing-interface"
1211

12+
"github.com/hashicorp/terraform-plugin-testing/internal/testingiface"
1313
"github.com/hashicorp/terraform-plugin-testing/statecheck"
1414
)
1515

16-
func runStateChecks(ctx context.Context, t testing.T, state *tfjson.State, stateChecks []statecheck.StateCheck) error {
16+
func runStateChecks(ctx context.Context, t testingiface.T, state *tfjson.State, stateChecks []statecheck.StateCheck) error {
1717
t.Helper()
1818

1919
var result []error

internal/plugintest/util.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"path"
1212
"path/filepath"
1313
"strings"
14-
"testing"
1514
)
1615

1716
func symlinkFile(src string, dest string) error {
@@ -145,42 +144,3 @@ func CopyDir(src, dest, baseDirName string) error {
145144

146145
return nil
147146
}
148-
149-
// TestExpectTFatal provides a wrapper for logic which should call
150-
// (*testing.T).Fatal() or (*testing.T).Fatalf().
151-
//
152-
// Since we do not want the wrapping test to fail when an expected test error
153-
// occurs, it is required that the testLogic passed in uses
154-
// github.com/mitchellh/go-testing-interface.RuntimeT instead of the real **
155-
// *testing.T.
156-
//
157-
// If Fatal() or Fatalf() is not called in the logic, the real (*testing.T).Fatal() will
158-
// be called to fail the test.
159-
func TestExpectTFatal(t *testing.T, testLogic func()) {
160-
t.Helper()
161-
162-
var recoverIface interface{}
163-
164-
func() {
165-
defer func() {
166-
recoverIface = recover()
167-
}()
168-
169-
testLogic()
170-
}()
171-
172-
if recoverIface == nil {
173-
t.Fatalf("expected t.Fatal(), got none")
174-
}
175-
176-
recoverStr, ok := recoverIface.(string)
177-
178-
if !ok {
179-
t.Fatalf("expected string from recover(), got: %v (%T)", recoverIface, recoverIface)
180-
}
181-
182-
// this string is hardcoded in github.com/mitchellh/go-testing-interface
183-
if !strings.HasPrefix(recoverStr, "testing.T failed, see logs for output") {
184-
t.Fatalf("expected t.Fatal(), got: %s", recoverStr)
185-
}
186-
}

0 commit comments

Comments
 (0)