package params import ( "testing" "resource-generator/internal/types" ) func TestAlignParamTypesInheritsNestedStructure(t *testing.T) { schema := []types.Param{{ Code: "jsonEnv", Type: "string", HasSubParams: true, SubParams: []types.Param{{ Code: "DB_PASS", Type: "string", }}, }} modify := []types.Param{{ Code: "jsonEnv", Type: "map", }} got := AlignParamTypes(modify, schema) if len(got) != 1 { t.Fatalf("expected one parameter, got %d", len(got)) } if !got[0].HasSubParams { t.Fatal("expected nested structure to be inherited") } if len(got[0].SubParams) != 1 || got[0].SubParams[0].Code != "DB_PASS" { t.Fatalf("expected schema sub-params to be inherited, got %#v", got[0].SubParams) } if got[0].Type != "string" { t.Fatalf("expected type to align with schema, got %q", got[0].Type) } }