Skip to content

Commit

Permalink
Move execution of ConfigStateChecks (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jan 23, 2024
1 parent 04cf3c9 commit 173d4b2
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions helper/resource/testing_new_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,26 @@ func testStepNewConfig(ctx context.Context, t testing.T, c TestCase, wd *plugint
}
}
}

// Run state checks
if len(step.ConfigStateChecks) > 0 {
var state *tfjson.State

err = runProviderCommand(ctx, t, func() error {
var err error
state, err = wd.State(ctx)
return err
}, wd, providers)

if err != nil {
return fmt.Errorf("Error retrieving post-apply, post-refresh state: %w", err)
}

err = runStateChecks(ctx, t, state, step.ConfigStateChecks)
if err != nil {
return fmt.Errorf("Post-apply refresh state check(s) failed:\n%w", err)
}
}
}

// Test for perpetual diffs by performing a plan, a refresh, and another plan
Expand Down Expand Up @@ -313,26 +333,6 @@ func testStepNewConfig(ctx context.Context, t testing.T, c TestCase, wd *plugint
}
}

// Run post-apply, post-refresh state checks
if len(step.ConfigStateChecks) > 0 {
var state *tfjson.State

err = runProviderCommand(ctx, t, func() error {
var err error
state, err = wd.State(ctx)
return err
}, wd, providers)

if err != nil {
return fmt.Errorf("Error retrieving post-apply, post-refresh state: %w", err)
}

err = runStateChecks(ctx, t, state, step.ConfigStateChecks)
if err != nil {
return fmt.Errorf("Post-apply refresh state check(s) failed:\n%w", err)
}
}

// check if plan is empty
if !planIsEmpty(plan, helper.TerraformVersion()) && !step.ExpectNonEmptyPlan {
var stdout string
Expand Down

0 comments on commit 173d4b2

Please sign in to comment.