Skip to content

Commit 202e715

Browse files
authored
Merge pull request #43184 from hashicorp/td-replace-PlanOnly-test-steps-2
Technical debt: Replace `PlanOnly` acceptance tests (services `g` - `w`)
2 parents 101895e + af9c3f1 commit 202e715

File tree

188 files changed

+3229
-1198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+3229
-1198
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
rules:
2+
- id: replace-planonly-checks
3+
languages: [go]
4+
message: Replace `PlanOnly` acceptance test steps with `plancheck`s
5+
paths:
6+
include:
7+
- "internal/service/*/*_test.go"
8+
patterns:
9+
- pattern: |
10+
{
11+
...,
12+
PlanOnly: true,
13+
...
14+
}
15+
severity: ERROR

internal/generate/tagstests/resource_test.go.gtpl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,14 @@ func {{ template "testname" . }}_tags_null(t *testing.T) {
492492
acctest.CtResourceTags: nil,
493493
{{ template "AdditionalTfVars" . }}
494494
},
495-
PlanOnly: true,
496-
ExpectNonEmptyPlan: false,
495+
ConfigPlanChecks: resource.ConfigPlanChecks{
496+
PreApply: []plancheck.PlanCheck{
497+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
498+
},
499+
PostApplyPostRefresh: []plancheck.PlanCheck{
500+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
501+
},
502+
},
497503
},
498504
{{- end }}
499505
},
@@ -567,8 +573,14 @@ func {{ template "testname" . }}_tags_EmptyMap(t *testing.T) {
567573
acctest.CtResourceTags: nil,
568574
{{ template "AdditionalTfVars" . }}
569575
},
570-
PlanOnly: true,
571-
ExpectNonEmptyPlan: false,
576+
ConfigPlanChecks: resource.ConfigPlanChecks{
577+
PreApply: []plancheck.PlanCheck{
578+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
579+
},
580+
PostApplyPostRefresh: []plancheck.PlanCheck{
581+
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop),
582+
},
583+
},
572584
},
573585
{{- end }}
574586
},

internal/sdkv2/schema.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ var IAMPolicyDocumentSchemaOptionalComputed = sync.OnceValue(jsonDocumentSchemaO
7777
// IAMPolicyDocumentSchemaRequired returns the standard schema for a required IAM policy JSON document.
7878
var IAMPolicyDocumentSchemaRequired = sync.OnceValue(jsonDocumentSchemaRequiredFunc(SuppressEquivalentIAMPolicyDocuments))
7979

80+
// IAMPolicyDocumentSchemaRequiredForceNew returns the standard schema for a required, force-new IAM policy JSON document.
81+
var IAMPolicyDocumentSchemaRequiredForceNew = sync.OnceValue(jsonDocumentSchemaRequiredForceNewFunc(SuppressEquivalentIAMPolicyDocuments))
82+
8083
// JSONDocumentSchemaOptionalForceNew returns the standard schema for an optional, force-new JSON document.
8184
var JSONDocumentSchemaOptionalForceNew = sync.OnceValue(jsonDocumentSchemaOptionalForceNewFunc(SuppressEquivalentJSONDocuments))
8285

@@ -136,3 +139,17 @@ func jsonDocumentSchemaRequiredFunc(diffSuppressFunc schema.SchemaDiffSuppressFu
136139
}
137140
}
138141
}
142+
143+
func jsonDocumentSchemaRequiredForceNewFunc(diffSuppressFunc schema.SchemaDiffSuppressFunc) func() *schema.Schema {
144+
return func() *schema.Schema {
145+
return &schema.Schema{
146+
Type: schema.TypeString,
147+
Required: true,
148+
ForceNew: true,
149+
ValidateFunc: validation.StringIsJSON,
150+
DiffSuppressFunc: diffSuppressFunc,
151+
DiffSuppressOnRefresh: true,
152+
StateFunc: NormalizeJsonStringSchemaStateFunc,
153+
}
154+
}
155+
}

internal/service/accessanalyzer/analyzer_tags_gen_test.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/acm/certificate_tags_gen_test.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/acmpca/certificate_authority_tags_gen_test.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/amp/rule_group_namespace_tags_gen_test.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/amp/workspace_tags_gen_test.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/amplify/app_tags_gen_test.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/amplify/branch_tags_gen_test.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)