Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rawNames from makeObjectTerraformInputs #1851

Merged
merged 7 commits into from
Apr 13, 2024
60 changes: 60 additions & 0 deletions pkg/tfbridge/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3129,6 +3129,32 @@ func Test_makeTerraformInputsNoDefaults(t *testing.T) {
//nolint:lll
expect: autogold.Expect(map[string]interface{}{"nested_resource": []interface{}{map[string]interface{}{"configuration": map[string]interface{}{"configurationValue": true}}}}),
},
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

testCaseName: "set_nested_block",
schemaMap: map[string]*schema.Schema{
"nested_resource": {
Optional: true,
Type: shim.TypeSet,
Elem: (&schema.Resource{
Schema: schemaMap(map[string]*schema.Schema{
"configuration": {
Type: shim.TypeMap,
Optional: true,
},
}),
}).Shim(),
},
},
propMap: resource.NewPropertyMapFromMap(map[string]interface{}{
"nestedResources": []map[string]interface{}{{
"configuration": map[string]interface{}{
"configurationValue": true,
},
}},
}),
//nolint:lll
expect: autogold.Expect(map[string]interface{}{"nested_resource": []interface{}{map[string]interface{}{"configuration": map[string]interface{}{"configurationValue": true}}}}),
},
{
testCaseName: "optional_config",
schemaMap: map[string]*schema.Schema{
Expand Down Expand Up @@ -3263,6 +3289,40 @@ func Test_makeTerraformInputsNoDefaults(t *testing.T) {
}),
expect: autogold.Expect(map[string]interface{}{"nil_property_value": nil}),
},
{
testCaseName: "set_attribute",
schemaMap: map[string]*schema.Schema{
"set_attribute": {
Type: shim.TypeSet,
Optional: true,
Elem: (&schema.Schema{Type: shim.TypeInt}).Shim(),
},
},
propMap: resource.PropertyMap{
"set_attribute": resource.NewProperty([]resource.PropertyValue{
resource.NewProperty(1.0),
resource.NewProperty(2.0),
}),
},
expect: autogold.Expect(map[string]interface{}{"set_attribute": []interface{}{1, 2}}),
},
{
testCaseName: "list_attribute",
schemaMap: map[string]*schema.Schema{
"set_attribute": {
Type: shim.TypeList,
Optional: true,
Elem: (&schema.Schema{Type: shim.TypeInt}).Shim(),
},
},
propMap: resource.PropertyMap{
"set_attribute": resource.NewProperty([]resource.PropertyValue{
resource.NewProperty(1.0),
resource.NewProperty(2.0),
}),
},
expect: autogold.Expect(map[string]interface{}{"set_attribute": []interface{}{1, 2}}),
},
// {
// testCaseName: "???",
// schemaMap: map[string]*schema.Schema{},
Expand Down