Skip to content

Commit

Permalink
Backport remaining fixes from v2.0.3.
Browse files Browse the repository at this point in the history
Backport #580 to restore pre-binary ExpectNonEmptyPlan behavior when
testing.

Backport #584 to use the latest terraform-exec and terraform-plugin-test
to take advantage of the fixed diff output.

Backport #581 to check the error on post-test destroy, warning there may
be dangling resources and surfacing the error.

This should bring the v1-maint branch in line with 2.0.3 in terms of
functionality and bug fixes.
  • Loading branch information
paddycarver committed Sep 22, 2020
1 parent 86c7583 commit 4bc4237
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ require (
github.com/hashicorp/hcl/v2 v2.3.0
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8
github.com/hashicorp/terraform-exec v0.9.0
github.com/hashicorp/terraform-exec v0.10.0
github.com/hashicorp/terraform-json v0.5.0
github.com/hashicorp/terraform-plugin-test/v2 v2.1.1
github.com/hashicorp/terraform-plugin-test/v2 v2.1.2
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 h1:+RyjwU+Gnd/aTJBPZVDNm903eXVjjqhbaR4Ypx3xYyY=
github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A=
github.com/hashicorp/terraform-exec v0.9.0 h1:NmCtcsnmPBU6P3cDeKD26bD72evsMhmuDLvuNRgrTHc=
github.com/hashicorp/terraform-exec v0.9.0/go.mod h1:tOT8j1J8rP05bZBGWXfMyU3HkLi1LWyqL3Bzsc3CJjo=
github.com/hashicorp/terraform-exec v0.10.0 h1:3nh/1e3u9gYRUQGOKWp/8wPR7ABlL2F14sZMZBrp+dM=
github.com/hashicorp/terraform-exec v0.10.0/go.mod h1:tOT8j1J8rP05bZBGWXfMyU3HkLi1LWyqL3Bzsc3CJjo=
github.com/hashicorp/terraform-json v0.5.0 h1:7TV3/F3y7QVSuN4r9BEXqnWqrAyeOtON8f0wvREtyzs=
github.com/hashicorp/terraform-json v0.5.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU=
github.com/hashicorp/terraform-plugin-test/v2 v2.1.1 h1:aATRyyPlEKkFYUweD2Hld9eep77qzJVu8wg0mgyUE50=
github.com/hashicorp/terraform-plugin-test/v2 v2.1.1/go.mod h1:HaW2G5cDTVyiEKt7PHC85YSM5BwvYl/rIko1g8Lg7qE=
github.com/hashicorp/terraform-plugin-test/v2 v2.1.2 h1:p96IIn+XpvVjw7AtN8y9MKxn0x69S7wtbGf7JgDJoIk=
github.com/hashicorp/terraform-plugin-test/v2 v2.1.2/go.mod h1:jerO5mrd+jVNALy8aiq+VZOg/CR8T2T1QR3jd6JKGOI=
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg=
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
Expand Down
5 changes: 4 additions & 1 deletion helper/resource/testing_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ func RunNewTest(t *testing.T, c TestCase, providers map[string]terraform.Resourc
}

if !stateIsEmpty(statePreDestroy) {
runPostTestDestroy(t, c, wd, c.ProviderFactories)
err := runPostTestDestroy(t, c, wd, c.ProviderFactories)
if err != nil {
t.Fatalf("Error running post-test destroy, there may be dangling resources: %s", err.Error())
}
}

wd.Close()
Expand Down
2 changes: 0 additions & 2 deletions helper/resource/testing_new_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ func testStepNewConfig(t *testing.T, c TestCase, wd *tftest.WorkingDir, step Tes
return fmt.Errorf("Error retrieving formatted plan output: %s", err)
}
return fmt.Errorf("After applying this test step, the plan was not empty.\nstdout:\n\n%s", stdout)
} else if step.ExpectNonEmptyPlan && planIsEmpty(plan) {
return fmt.Errorf("Expected a non-empty plan, but got an empty plan!")
}

// do a refresh
Expand Down

0 comments on commit 4bc4237

Please sign in to comment.