Skip to content

Commit 47633ce

Browse files
authored
chore: Fixes converting to TPF by including all attributes in replication_specs (#2894)
1 parent f379847 commit 47633ce

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

internal/testutil/acc/advanced_cluster_schema_v2.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ func getReplicationSpecs(t *testing.T, body *hclsyntax.Body) cty.Value {
146146
assert.Equal(t, name, block.Type, "unexpected block type: %s", block.Type)
147147
vals = append(vals, hcl.GetAttrVal(t, block.Body))
148148
}
149-
return cty.ObjectVal(map[string]cty.Value{
149+
attributeValues := map[string]cty.Value{
150150
name: cty.TupleVal(vals),
151-
})
151+
}
152+
hcl.AddAttributes(t, body, attributeValues)
153+
return cty.ObjectVal(attributeValues)
152154
}

internal/testutil/acc/advanced_cluster_schema_v2_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func TestConvertAdvancedClusterToSchemaV2(t *testing.T) {
5656
cluster_type = "SHARDED"
5757
5858
replication_specs {
59+
zone_name = "zone1"
5960
region_configs {
6061
electable_specs {
6162
disk_size_gb = 10
@@ -198,7 +199,8 @@ func TestConvertAdvancedClusterToSchemaV2(t *testing.T) {
198199
priority = 6
199200
provider_name = "AZURE"
200201
region_name = "US_EAST_2"
201-
}]
202+
}]
203+
zone_name = "zone1"
202204
}, {
203205
region_configs = [{
204206
analytics_specs = {

internal/testutil/hcl/common.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,20 @@ func getTF() *tfexec.Terraform {
5353
func GetAttrVal(t *testing.T, body *hclsyntax.Body) cty.Value {
5454
t.Helper()
5555
ret := make(map[string]cty.Value)
56+
AddAttributes(t, body, ret)
57+
for _, block := range body.Blocks {
58+
ret[block.Type] = GetAttrVal(t, block.Body)
59+
}
60+
return cty.ObjectVal(ret)
61+
}
62+
63+
func AddAttributes(t *testing.T, body *hclsyntax.Body, ret map[string]cty.Value) {
64+
t.Helper()
5665
for name, attr := range body.Attributes {
5766
val, diags := attr.Expr.Value(nil)
5867
require.False(t, diags.HasErrors(), "failed to parse attribute %s: %s", name, diags.Error())
5968
ret[name] = val
6069
}
61-
for _, block := range body.Blocks {
62-
ret[block.Type] = GetAttrVal(t, block.Body)
63-
}
64-
return cty.ObjectVal(ret)
6570
}
6671

6772
func PrettyHCL(t *testing.T, content string) string {

0 commit comments

Comments
 (0)