Skip to content

Commit 4ef6dac

Browse files
authored
resourceIdentity: testing generation template (#14993)
2 parents 1cc2cb1 + 06179ef commit 4ef6dac

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,29 @@
1818
package {{ $.Res.PackageName }}_test
1919

2020
import (
21-
{{- if not $.Res.ExcludeDelete }}
21+
{{- if not $.Res.ExcludeDelete }}
2222
{{- if not $.Res.CustomCode.TestCheckDestroy }}
2323
"fmt"
2424
{{- end }}
2525
"strings"
26-
{{- end }}
26+
{{- end }}
2727
"testing"
2828

2929
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
3030
{{- if not $.Res.ExcludeDelete }}
3131
"github.com/hashicorp/terraform-plugin-testing/terraform"
3232
{{- end }}
33+
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
34+
"github.com/hashicorp/terraform-plugin-testing/statecheck"
35+
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
36+
"github.com/hashicorp/terraform-plugin-testing/tfversion"
3337

3438
"{{ $.ImportPath }}/acctest"
3539
"{{ $.ImportPath }}/envvar"
3640
"{{ $.ImportPath }}/tpgresource"
3741
transport_tpg "{{ $.ImportPath }}/transport"
3842
)
39-
{{ range $e := $.Res.TestExamples }}
43+
{{ range $i, $e := $.Res.TestExamples }}
4044
func TestAcc{{ $e.TestSlug $.Res.ProductMetadata.Name $.Res.Name }}(t *testing.T) {
4145
{{- if $e.SkipTest }}
4246
t.Skip("{{$e.SkipTest}}")
@@ -96,6 +100,17 @@ func TestAcc{{ $e.TestSlug $.Res.ProductMetadata.Name $.Res.Name }}(t *testing.T
96100
ImportStateVerifyIgnore: {{ $.Res.IgnoreReadPropertiesToString $e }},
97101
{{- end }}
98102
},
103+
{{- end }}
104+
{{- if eq $i 0 }}
105+
{{- if lt (index $.Res.ProductMetadata.ApiName 0) 'a' }}
106+
107+
{
108+
ResourceName: "{{ $.Res.TerraformName }}.{{ $e.PrimaryResourceId }}",
109+
RefreshState: true,
110+
ExpectNonEmptyPlan: true,
111+
ImportStateKind: resource.ImportBlockWithResourceIdentity,
112+
},
113+
{{- end }}
99114
{{- end }}
100115
},
101116
})

0 commit comments

Comments
 (0)