Skip to content

Commit

Permalink
[ignore] Generator template fix for datasource to not include default…
Browse files Browse the repository at this point in the history
… for required attributes when key is the same
  • Loading branch information
akinross authored and lhercot committed Nov 19, 2024
1 parent 974c43d commit 2904cbc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
48 changes: 25 additions & 23 deletions gen/templates/datasource_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,42 @@ func TestAccDataSource{{$.resourceClassName}}{{if .class_name}}With{{capitalize
{{- range $key, $value := $.datasource_required}}
{{- if eq $key "target_dn" }}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$key}}", "{{getTestTargetDn $.targets $.resourceName $value false $target_classes 0 false}}"),
{{- else }}
{{- if not (definedInList $.exclude_attributes $key) }}
{{- else }}
{{- if not (definedInList $.exclude_attributes $key) }}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$key}}", "{{$value}}"),
{{- end }}
{{- end}}
{{- end }}
{{- end}}
{{- end}}
{{- range $key, $value := $.default}}
{{- if eq $key "version_mismatch" }}
{{- range $version, $attributes := $value }}
{{- if not (definedInMap $key $.datasource_required)}}
{{- if eq $key "version_mismatch" }}
{{- range $version, $attributes := $value }}
composeAggregateTestCheckFuncWithVersion(t, "{{$version}}", ">",{{- range $attributeName, $attributeValue := $attributes}}
{{- if not (definedInList $.exclude_attributes $attributeName) }}
{{- if (isInterfaceSlice $attributeValue)}}
{{- if not (definedInList $.exclude_attributes $attributeName) }}
{{- if (isInterfaceSlice $attributeValue)}}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$attributeName}}.#", "{{len $attributeValue}}"),
{{- range $index, $subvalue := $attributeValue}}
{{- range $index, $subvalue := $attributeValue}}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$attributeName}}.{{$index}}", "{{$subvalue}}"),
{{- end}}
{{- else}}
{{- end}}
{{- else}}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$attributeName}}", "{{$attributeValue}}"),
{{- end}}
{{- end}}
{{- end}}),
{{- end}}
{{- else}}
{{- if not (definedInList $.exclude_attributes $key) }}
{{- if (isInterfaceSlice $value)}}
{{- end}}
{{- end}}
{{- end}}),
{{- end}}
{{- else}}
{{- if not (definedInList $.exclude_attributes $key) }}
{{- if (isInterfaceSlice $value)}}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$key}}.#", "{{len $value}}"),
{{- range $index, $subvalue := $value}}
{{- range $index, $subvalue := $value}}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$key}}.{{$index}}", "{{$subvalue}}"),
{{- end}}
{{- else}}
{{- end}}
{{- else}}
resource.TestCheckResourceAttr("data.aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$key}}", "{{$value}}"),
{{- end}}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
{{- range $index, $key := $.read_only}}
resource.TestCheckResourceAttrSet("data.aci_{{$.resourceName}}.test", "{{$key}}"),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2904cbc

Please sign in to comment.