Skip to content

Commit

Permalink
[ignore] Add a test to check semantic equality for customtype attribu…
Browse files Browse the repository at this point in the history
…tes.
  • Loading branch information
gmicol committed Aug 26, 2024
1 parent 28c0f82 commit 206ca0f
Showing 20 changed files with 335 additions and 0 deletions.
55 changes: 55 additions & 0 deletions gen/templates/resource_test.go.tmpl
Original file line number Diff line number Diff line change
@@ -407,6 +407,22 @@ func TestAccResource{{$.resourceClassName}}With{{capitalize .class_name}}(t *tes
),
},
{{- end}}
{{- if $.customtype}}
// Update with minimum config and customtype semantic equivalent values
{
Config: testConfig{{$.resourceClassName}}CustomTypeDependencyWith{{capitalize .class_name}},
ExpectNonEmptyPlan: {{.class_in_parent}},
Check: resource.ComposeAggregateTestCheckFunc(
{{- range $key, $value := $.customtype}}
{{- if eq $key "target_dn" }}
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$key}}", "{{getTestTargetDn $.targets $.resourceName $value false $target_classes 0}}"),
{{- else }}
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}", "{{$key}}", "{{$value}}"),
{{- end }}
{{- end}}
),
},
{{- end}}
},
})
} {{- end}}
@@ -800,6 +816,21 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) {
),
},
{{- end}}
{{- if $.customtype}}
// Update with minimum config and customtype semantic equivalent values
{
Config: testConfig{{$.resourceClassName}}CustomType,
Check: resource.ComposeAggregateTestCheckFunc(
{{- range $key, $value := $.customtype}}
{{- if eq $key "target_dn" }}
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}", "{{getTestTargetDn $.targets $.resourceName $value false nil 0}}"),
{{- else }}
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}", "{{$value}}"),
{{- end }}
{{- end}}
),
},
{{- end}}
},
})
}
@@ -1031,6 +1062,21 @@ resource "aci_{{$.resourceName}}" "test{{- if eq $.resourceClassName $parentClas
{{- end}}
{{- end}}
}
`
{{- end}}

{{if $.customtype}}
const testConfig{{$.resourceClassName}}CustomTypeDependencyWith{{capitalize .class_name}} = {{- if $dependencies }} testDependencyConfig{{$.resourceClassName}} + {{- end }} testConfig{{capitalize .class_name}}Min{{- if ne .parent_dependency ""}}DependencyWith{{capitalize .parent_dependency}}{{if and (ne .parent_dependency_name nil) (ne .parent_dependency_name "")}}{{capitalize .parent_dependency_name }}{{- end }}{{- end}} + `
resource "aci_{{$.resourceName}}" "test{{- if eq $.resourceClassName $parentClassName }}_1{{- end }}" {
parent_dn = {{.parent_dn}}
{{- range $key, $value := $.customtype}}
{{- if eq $key "target_dn" }}{{$attributeValue := getTestTargetDn $.targets $.resourceName $value true $target_classes 0}}
{{$key}} = {{if containsString $attributeValue "."}}{{$attributeValue}}{{else}}"{{$attributeValue}}"{{end}}
{{- else }}
{{$key}} = "{{$value}}"
{{- end }}
{{- end}}
}
`
{{- end}}
{{- end}}
@@ -1193,6 +1239,15 @@ resource "aci_{{$.resourceName}}" "test" {
{{- end}}
}
`
{{- end}}

{{if $.customtype}}
const testConfig{{.resourceClassName}}CustomType = `
resource "aci_{{$.resourceName}}" "test" {
{{- range $key, $value := $.customtype}}
{{$key}} = "{{$value}}"
{{- end}}
}
`
{{- end}}
{{- end}}
11 changes: 11 additions & 0 deletions gen/templates/testvars.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -51,6 +51,17 @@ resource_required:
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName $testValue "resource_required" 0 $.Definitions}}"
{{- end}}
{{- end}}
{{- if .HasCustomTypeProperties}}

customtype:
{{- range .Properties}}{{$testValue := createTestValue .SnakeCaseName}}{{$overwritePropertyName := overwriteProperty .PkgName .SnakeCaseName $.Definitions}}
{{- if .HasCustomType}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: {{$validValuesMap := .ValidValuesMap}}{{range $key, $value := $validValuesMap}}{{if or (ne $value "unspecified") (eq (len $validValuesMap) 1)}}"{{$key}}"{{break}}{{end}}{{end}}
{{- else if or .IsNaming (or .IsRequired (isRequiredInTestValue .PkgName $overwritePropertyName $.Definitions "resource_required"))}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: "{{overwritePropertyValue .PkgName $overwritePropertyName $testValue "resource_required" 0 $.Definitions}}"
{{- end}}
{{- end}}
{{- end}}
{{- end }}
{{- if .HasReadOnlyProperties}}

4 changes: 4 additions & 0 deletions gen/testvars/fvAEPg.yaml
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ datasource_required:
resource_required:
name: "test_name"

customtype:
name: "test_name"
priority: "1"

read_only:
- "pc_tag"

4 changes: 4 additions & 0 deletions gen/testvars/fvRsCons.yaml
Original file line number Diff line number Diff line change
@@ -15,6 +15,10 @@ datasource_required:
resource_required:
contract_name: "test_tn_vz_br_cp_name"

customtype:
priority: "1"
contract_name: "test_tn_vz_br_cp_name"

all:
annotation: "annotation"
priority: "level1"
4 changes: 4 additions & 0 deletions gen/testvars/fvRsConsIf.yaml
Original file line number Diff line number Diff line change
@@ -15,6 +15,10 @@ datasource_required:
resource_required:
imported_contract_name: "test_tn_vz_cp_if_name"

customtype:
priority: "1"
imported_contract_name: "test_tn_vz_cp_if_name"

all:
annotation: "annotation"
priority: "level1"
4 changes: 4 additions & 0 deletions gen/testvars/fvRsProv.yaml
Original file line number Diff line number Diff line change
@@ -16,6 +16,10 @@ datasource_required:
resource_required:
contract_name: "test_tn_vz_br_cp_name"

customtype:
priority: "1"
contract_name: "test_tn_vz_br_cp_name"

all:
annotation: "annotation"
match_criteria: "All"
4 changes: 4 additions & 0 deletions gen/testvars/mgmtInstP.yaml
Original file line number Diff line number Diff line change
@@ -17,6 +17,10 @@ datasource_required:
resource_required:
name: "test_name"

customtype:
name: "test_name"
priority: "1"

all:
annotation: "annotation"
description: "description_1"
4 changes: 4 additions & 0 deletions gen/testvars/mgmtRsOoBCons.yaml
Original file line number Diff line number Diff line change
@@ -15,6 +15,10 @@ datasource_required:
resource_required:
out_of_band_contract_name: "test_tn_vz_oob_br_cp_name"

customtype:
priority: "1"
out_of_band_contract_name: "test_tn_vz_oob_br_cp_name"

all:
annotation: "annotation"
priority: "level1"
7 changes: 7 additions & 0 deletions gen/testvars/netflowExporterPol.yaml
Original file line number Diff line number Diff line change
@@ -27,6 +27,13 @@ resource_required:
name: "netfow_exporter"
source_ip_address: "1.1.1.1/10"

customtype:
qos_dscp_value: "0"
destination_ip_address: "2.2.2.1"
destination_port: "110"
name: "netfow_exporter"
source_ip_address: "1.1.1.1/10"

all:
annotation: "annotation"
description: "description_1"
11 changes: 11 additions & 0 deletions gen/testvars/qosDppPol.yaml
Original file line number Diff line number Diff line change
@@ -39,6 +39,17 @@ datasource_required:
resource_required:
name: "test_name"

customtype:
excessive_burst: "0xffffffffffffffff"
burst: "0xffffffffffffffff"
conform_mark_cos: "0xffff"
conform_mark_dscp: "0xffff"
exceed_mark_cos: "0xffff"
exceed_mark_dscp: "0xffff"
name: "test_name"
violate_mark_cos: "0xffff"
violate_mark_dscp: "0xffff"

all:
admin_state: "disabled"
annotation: "annotation"
5 changes: 5 additions & 0 deletions gen/testvars/vzOOBBrCP.yaml
Original file line number Diff line number Diff line change
@@ -22,6 +22,11 @@ datasource_required:
resource_required:
name: "test_name"

customtype:
name: "test_name"
priority: "1"
target_dscp: "0"

all:
annotation: "annotation"
description: "description_1"
17 changes: 17 additions & 0 deletions internal/provider/resource_aci_application_epg_test.go

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

31 changes: 31 additions & 0 deletions internal/provider/resource_aci_data_plane_policing_policy_test.go

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.

23 changes: 23 additions & 0 deletions internal/provider/resource_aci_netflow_exporter_policy_test.go

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

17 changes: 17 additions & 0 deletions internal/provider/resource_aci_out_of_band_contract_test.go

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

Loading

0 comments on commit 206ca0f

Please sign in to comment.