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

chore: PoC - handle merging computability in nested attributes #2722

Merged
Prev Previous commit
Next Next commit
minor
maastha committed Oct 22, 2024
commit 1fd92b3b98d8640975c5c64571f9566c0ef6da45
79 changes: 0 additions & 79 deletions tools/codegen/codespec/api_to_provider_spec_mapper_test.go
Original file line number Diff line number Diff line change
@@ -360,82 +360,3 @@ func TestConvertToProviderSpec_nested_schemaOverrides(t *testing.T) {
})
}
}

func TestConvertToProviderSpec_nested_schemaOverrides(t *testing.T) {
testCases := map[string]convertToSpecTestCase{
"Valid input": {
inputOpenAPISpecPath: "testdata/api-spec.yml",
inputConfigPath: "testdata/config-nested-schema-overrides.yml",
inputResourceName: "test_resource_with_nested_attr_overrides",

expectedResult: &codespec.Model{
Resources: []codespec.Resource{{
Schema: &codespec.Schema{
Description: conversion.StringPtr(testResourceDesc),
Attributes: codespec.Attributes{
{
Name: "project_id",
ComputedOptionalRequired: codespec.Required,
String: &codespec.StringAttribute{},
Description: conversion.StringPtr(testPathParamDesc),
},
{
Name: "nested_list_array_attr",
ComputedOptionalRequired: codespec.Required,
ListNested: &codespec.ListNestedAttribute{
NestedObject: codespec.NestedAttributeObject{
Attributes: codespec.Attributes{
{
Name: "inner_num_attr_alias",
ComputedOptionalRequired: codespec.Required,
Int64: &codespec.Int64Attribute{},
Description: conversion.StringPtr("Overridden inner_num_attr_alias description"),
},
},
},
},
Description: conversion.StringPtr(testFieldDesc),
},
{
Name: "outer_object",
ComputedOptionalRequired: codespec.Computed,
SingleNested: &codespec.SingleNestedAttribute{
NestedObject: codespec.NestedAttributeObject{
Attributes: codespec.Attributes{
{
Name: "nested_level1",
ComputedOptionalRequired: codespec.Computed,
SingleNested: &codespec.SingleNestedAttribute{
NestedObject: codespec.NestedAttributeObject{
Attributes: codespec.Attributes{
{
Name: "level_field1_alias",
ComputedOptionalRequired: codespec.Computed,
String: &codespec.StringAttribute{},
Description: conversion.StringPtr("Overridden level_field1_alias description"),
},
},
},
},
},
},
},
},
},
},
},
Name: "test_resource_with_nested_attr_overrides",
},
},
},
},
}

for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
result, err := codespec.ToCodeSpecModel(tc.inputOpenAPISpecPath, tc.inputConfigPath, tc.inputResourceName)
require.NoError(t, err)
assert.Equal(t, tc.expectedResult, result, "Expected result to match the specified structure")
})
}
}