Skip to content

Commit

Permalink
Add some additional test cases for "Test_makeTerraformInputsNoDefaults"
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Apr 13, 2024
1 parent ddb54e8 commit 69f75b8
Showing 1 changed file with 60 additions and 0 deletions.
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}}}}),
},
{
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

0 comments on commit 69f75b8

Please sign in to comment.