Skip to content

Commit 5bc6ef2

Browse files
committed
minor fixes
1 parent 22cffc6 commit 5bc6ef2

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

mmv1/api/resource/step.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func validateRegexForContents(r *regexp.Regexp, contents string, configPath stri
146146
// Executes step configuration templates for documentation and tests
147147
func (s *Step) SetHCLText(sysfs fs.FS) {
148148
originalPrefixedVars := s.PrefixedVars
149-
// originalVars := s.Vars
149+
originalVars := s.Vars
150150
originalTestEnvVars := s.TestEnvVars
151151
docTestEnvVars := make(map[string]string)
152152
docs_defaults := map[string]string{
@@ -216,6 +216,7 @@ func (s *Step) SetHCLText(sysfs fs.FS) {
216216

217217
s.PrefixedVars = testPrefixedVars
218218
s.TestEnvVars = testTestEnvVars
219+
s.Vars = testVars
219220
s.TestHCLText = s.ExecuteTemplate(sysfs)
220221
s.TestHCLText = regexp.MustCompile(`\n\n$`).ReplaceAllString(s.TestHCLText, "\n")
221222
// Remove region tags
@@ -225,6 +226,7 @@ func (s *Step) SetHCLText(sysfs fs.FS) {
225226

226227
// Reset the step
227228
s.PrefixedVars = originalPrefixedVars
229+
s.Vars = originalVars
228230
s.TestEnvVars = originalTestEnvVars
229231
}
230232

mmv1/templates/terraform/iam/iam_test_setup.go.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- define "IamTestSetupSample" }}
2-
{{ $config := $.FirstTestConfig }}
3-
{{ $sample := $config.Sample }}
4-
{{ $step := $config.Step }}
2+
{{- $config := $.FirstTestConfig }}
3+
{{- $sample := $config.Sample }}
4+
{{- $step := $config.Step }}
55
{{- if $sample.BootstrapIam }}
66
acctest.BootstrapIamMembers(t, []acctest.IamMember{
77
{{- range $iam := $sample.BootstrapIam }}

mmv1/templates/terraform/samples/base_configs/test_file.go.tmpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
package {{ $.Res.PackageName }}_test
1919

20+
{{- $needsPlancheck := false -}}
21+
{{- range $s := $.Res.TestSamples -}}
22+
{{- if gt (len $s.TestSteps) 1 -}}
23+
{{- $needsPlancheck = true -}}
24+
{{- end -}}
25+
{{- end -}}
26+
2027
import (
2128
"fmt"
2229
"log"
@@ -26,7 +33,9 @@ import (
2633
"time"
2734

2835
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
36+
{{- if $needsPlancheck }}
2937
"github.com/hashicorp/terraform-plugin-testing/plancheck"
38+
{{- end }}
3039
"github.com/hashicorp/terraform-plugin-testing/terraform"
3140

3241
"{{ $.ImportPath }}/acctest"

0 commit comments

Comments
 (0)