Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ require (
github.com/hashicorp/go-version v1.7.0
github.com/hashicorp/hc-install v0.9.2
github.com/hashicorp/hcl/v2 v2.24.0
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/terraform-exec v0.24.0
github.com/hashicorp/terraform-json v0.27.2
github.com/hashicorp/terraform-plugin-go v0.29.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-log v0.10.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1
github.com/mitchellh/go-testing-interface v1.14.1
github.com/zclconf/go-cty v1.17.0
Expand All @@ -34,6 +33,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.7.0 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-registry-address v0.4.0 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ github.com/hashicorp/terraform-json v0.27.2 h1:BwGuzM6iUPqf9JYM/Z4AF1OJ5VVJEEzoK
github.com/hashicorp/terraform-json v0.27.2/go.mod h1:GzPLJ1PLdUG5xL6xn1OXWIjteQRT2CNT9o/6A9mi9hE=
github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+9JxAltQyDMpq5mU=
github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-log v0.10.0 h1:eu2kW6/QBVdN4P3Ju2WiB2W3ObjkAsyfBsL3Wh1fj3g=
github.com/hashicorp/terraform-plugin-log v0.10.0/go.mod h1:/9RR5Cv2aAbrqcTSdNmY1NRHP4E3ekrXRGjqORpXyB0=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 h1:mlAq/OrMlg04IuJT7NpefI1wwtdpWudnEmjuQs04t/4=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU=
github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk=
Expand Down
140 changes: 0 additions & 140 deletions helper/logging/logging.go

This file was deleted.

4 changes: 2 additions & 2 deletions helper/resource/plan_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"errors"

tfjson "github.com/hashicorp/terraform-json"
"github.com/hashicorp/terraform-plugin-testing/internal/testing/hack"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/mitchellh/go-testing-interface"
)

func runPlanChecks(ctx context.Context, t testing.T, plan *tfjson.Plan, planChecks []plancheck.PlanCheck) error {
func runPlanChecks(ctx context.Context, t hack.BaseT, plan *tfjson.Plan, planChecks []plancheck.PlanCheck) error {
t.Helper()

var result []error
Expand Down
10 changes: 5 additions & 5 deletions helper/resource/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/mitchellh/go-testing-interface"

"github.com/hashicorp/terraform-plugin-testing/internal/logging"
"github.com/hashicorp/terraform-plugin-testing/internal/plugintest"
"github.com/hashicorp/terraform-plugin-testing/internal/testing/hack"
)

// protov5ProviderFactory is a function which is called to start a protocol
Expand Down Expand Up @@ -114,7 +114,7 @@ type providerFactories struct {
protov6 protov6ProviderFactories
}

func runProviderCommandApplyRefreshOnly(ctx context.Context, t testing.T, wd *plugintest.WorkingDir, factories *providerFactories) error {
func runProviderCommandApplyRefreshOnly(ctx context.Context, t hack.BaseT, wd *plugintest.WorkingDir, factories *providerFactories) error {
t.Helper()

fn := func() error {
Expand All @@ -123,7 +123,7 @@ func runProviderCommandApplyRefreshOnly(ctx context.Context, t testing.T, wd *pl
return runProviderCommand(ctx, t, wd, factories, fn)
}

func runProviderCommandCreatePlan(ctx context.Context, t testing.T, wd *plugintest.WorkingDir, factories *providerFactories) error {
func runProviderCommandCreatePlan(ctx context.Context, t hack.BaseT, wd *plugintest.WorkingDir, factories *providerFactories) error {
t.Helper()

fn := func() error {
Expand All @@ -132,7 +132,7 @@ func runProviderCommandCreatePlan(ctx context.Context, t testing.T, wd *pluginte
return runProviderCommand(ctx, t, wd, factories, fn)
}

func runProviderCommandSavedPlan(ctx context.Context, t testing.T, wd *plugintest.WorkingDir, factories *providerFactories) (*tfjson.Plan, error) {
func runProviderCommandSavedPlan(ctx context.Context, t hack.BaseT, wd *plugintest.WorkingDir, factories *providerFactories) (*tfjson.Plan, error) {
t.Helper()

var plan *tfjson.Plan
Expand All @@ -149,7 +149,7 @@ func runProviderCommandSavedPlan(ctx context.Context, t testing.T, wd *plugintes
return plan, nil
}

func runProviderCommand(ctx context.Context, t testing.T, wd *plugintest.WorkingDir, factories *providerFactories, f func() error) error {
func runProviderCommand(ctx context.Context, t hack.BaseT, wd *plugintest.WorkingDir, factories *providerFactories, f func() error) error {
// don't point to this as a test failure location
// point to whatever called it
t.Helper()
Expand Down
4 changes: 2 additions & 2 deletions helper/resource/query/query_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"fmt"

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

"github.com/hashicorp/terraform-plugin-testing/internal/testing/hack"
"github.com/hashicorp/terraform-plugin-testing/querycheck"
)

func RunQueryChecks(ctx context.Context, t testing.T, query []tfjson.LogMsg, queryChecks []querycheck.QueryResultCheck) error {
func RunQueryChecks(ctx context.Context, t hack.BaseT, query []tfjson.LogMsg, queryChecks []querycheck.QueryResultCheck) error {
t.Helper()

var result []error
Expand Down
4 changes: 2 additions & 2 deletions helper/resource/state_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"errors"

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

"github.com/hashicorp/terraform-plugin-testing/internal/testing/hack"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
)

func runStateChecks(ctx context.Context, t testing.T, state *tfjson.State, stateChecks []statecheck.StateCheck) error {
func runStateChecks(ctx context.Context, t hack.BaseT, state *tfjson.State, stateChecks []statecheck.StateCheck) error {
t.Helper()

var result []error
Expand Down
5 changes: 2 additions & 3 deletions helper/resource/testcase_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"context"
"fmt"

"github.com/mitchellh/go-testing-interface"

"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/internal/logging"
"github.com/hashicorp/terraform-plugin-testing/internal/testing/hack"
"github.com/hashicorp/terraform-plugin-testing/internal/teststep"
)

Expand Down Expand Up @@ -51,7 +50,7 @@ func (c TestCase) hasProviders(_ context.Context) bool {
// - No overlapping ExternalProviders and Providers entries
// - No overlapping ExternalProviders and ProviderFactories entries
// - TestStep validations performed by the (TestStep).validate() method.
func (c TestCase) validate(ctx context.Context, t testing.T) error {
func (c TestCase) validate(ctx context.Context, t hack.BaseT) error {
logging.HelperResourceTrace(ctx, "Validating TestCase")

if len(c.Steps) == 0 {
Expand Down
10 changes: 5 additions & 5 deletions helper/resource/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/hashicorp/terraform-plugin-testing/querycheck"

"github.com/mitchellh/go-testing-interface"
testing "github.com/hashicorp/terraform-plugin-testing/internal/testing/hack"

"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
Expand Down Expand Up @@ -887,7 +887,7 @@ type RefreshPlanChecks struct {
// tests to occur against the same resource or service (e.g. random naming).
//
// Test() function requirements and documentation also apply to this function.
func ParallelTest(t testing.T, c TestCase) {
func ParallelTest(t testing.BaseT, c TestCase) {
t.Helper()
t.Parallel()
Test(t, c)
Expand All @@ -899,7 +899,7 @@ func ParallelTest(t testing.T, c TestCase) {
// set to some non-empty value. This is to avoid test cases surprising
// a user by creating real resources.
//
// Use the ParallelTest() function to automatically set (*testing.T).Parallel()
// Use the ParallelTest() function to automatically set (*testing.BaseT).Parallel()
// to enable testing concurrency. Use the UnitTest() function to automatically
// set the TestCase type IsUnitTest field.
//
Expand All @@ -919,7 +919,7 @@ func ParallelTest(t testing.T, c TestCase) {
//
// Refer to the Env prefixed constants for additional details about these
// environment variables, and others, that control testing functionality.
func Test(t testing.T, c TestCase) {
func Test(t testing.BaseT, c TestCase) {
t.Helper()

ctx := context.Background()
Expand Down Expand Up @@ -999,7 +999,7 @@ func Test(t testing.T, c TestCase) {
// have any external dependencies.
//
// Test() function requirements and documentation also apply to this function.
func UnitTest(t testing.T, c TestCase) {
func UnitTest(t testing.BaseT, c TestCase) {
t.Helper()

c.IsUnitTest = true
Expand Down
12 changes: 6 additions & 6 deletions helper/resource/testing_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/go-version"
tfjson "github.com/hashicorp/terraform-json"
"github.com/mitchellh/go-testing-interface"

"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/internal/logging"
"github.com/hashicorp/terraform-plugin-testing/internal/plugintest"
"github.com/hashicorp/terraform-plugin-testing/internal/testing/hack"
"github.com/hashicorp/terraform-plugin-testing/internal/teststep"
"github.com/hashicorp/terraform-plugin-testing/terraform"
)

func runPostTestDestroy(ctx context.Context, t testing.T, c TestCase, wd *plugintest.WorkingDir, providers *providerFactories, statePreDestroy *terraform.State) error {
func runPostTestDestroy(ctx context.Context, t hack.BaseT, c TestCase, wd *plugintest.WorkingDir, providers *providerFactories, statePreDestroy *terraform.State) error {
t.Helper()

err := runProviderCommand(ctx, t, wd, providers, func() error {
Expand All @@ -48,7 +48,7 @@ func runPostTestDestroy(ctx context.Context, t testing.T, c TestCase, wd *plugin
return nil
}

func runNewTest(ctx context.Context, t testing.T, c TestCase, helper *plugintest.Helper) {
func runNewTest(ctx context.Context, t hack.BaseT, c TestCase, helper *plugintest.Helper) {
t.Helper()

wd := helper.RequireNewWorkingDir(ctx, t, c.WorkingDir)
Expand Down Expand Up @@ -492,7 +492,7 @@ func runNewTest(ctx context.Context, t testing.T, c TestCase, helper *plugintest
}
}

func getState(ctx context.Context, t testing.T, wd *plugintest.WorkingDir) (*tfjson.State, *terraform.State, error) {
func getState(ctx context.Context, t hack.BaseT, wd *plugintest.WorkingDir) (*tfjson.State, *terraform.State, error) {
t.Helper()

jsonState, err := wd.State(ctx)
Expand Down Expand Up @@ -532,7 +532,7 @@ func planIsEmpty(plan *tfjson.Plan, tfVersion *version.Version) bool {
return true
}

func testIDRefresh(ctx context.Context, t testing.T, c TestCase, wd *plugintest.WorkingDir, step TestStep, r *terraform.ResourceState, providers *providerFactories, stepIndex int, helper *plugintest.Helper) error {
func testIDRefresh(ctx context.Context, t hack.BaseT, c TestCase, wd *plugintest.WorkingDir, step TestStep, r *terraform.ResourceState, providers *providerFactories, stepIndex int, helper *plugintest.Helper) error {
t.Helper()

// Build the state. The state is just the resource with an ID. There
Expand Down Expand Up @@ -674,7 +674,7 @@ func testIDRefresh(ctx context.Context, t testing.T, c TestCase, wd *plugintest.
return nil
}

func copyWorkingDir(ctx context.Context, t testing.T, stepNumber int, wd *plugintest.WorkingDir) {
func copyWorkingDir(ctx context.Context, t hack.BaseT, stepNumber int, wd *plugintest.WorkingDir) {
if os.Getenv(plugintest.EnvTfAccPersistWorkingDir) == "" {
return
}
Expand Down
Loading
Loading