Skip to content

Commit

Permalink
Improves name for plural/singular field name tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavison committed Aug 8, 2024
1 parent 73ec960 commit fd39cae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions internal/framework/flex/auto_expand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func TestExpand(t *testing.T) {
},
},
"plural ordinary field names": {
Source: &tfListOfNestedObject2{
Source: &tfSingluarListOfNestedObjects{
Field: fwtypes.NewListNestedObjectValueOfPtrMust(context.Background(), &tfSingleStringField{
Field1: types.StringValue("a"),
}),
Expand All @@ -342,9 +342,9 @@ func TestExpand(t *testing.T) {
Fields: []awsSingleStringValue{{Field1: "a"}},
},
expectedLogLines: []map[string]any{
infoExpanding(reflect.TypeFor[*tfListOfNestedObject2](), reflect.TypeFor[*awsPluralSliceOfNestedObjectValues]()),
infoConverting(reflect.TypeFor[tfListOfNestedObject2](), reflect.TypeFor[*awsPluralSliceOfNestedObjectValues]()),
traceMatchedFields("Field", reflect.TypeFor[tfListOfNestedObject2](), "Fields", reflect.TypeFor[*awsPluralSliceOfNestedObjectValues]()),
infoExpanding(reflect.TypeFor[*tfSingluarListOfNestedObjects](), reflect.TypeFor[*awsPluralSliceOfNestedObjectValues]()),
infoConverting(reflect.TypeFor[tfSingluarListOfNestedObjects](), reflect.TypeFor[*awsPluralSliceOfNestedObjectValues]()),
traceMatchedFields("Field", reflect.TypeFor[tfSingluarListOfNestedObjects](), "Fields", reflect.TypeFor[*awsPluralSliceOfNestedObjectValues]()),
infoConvertingWithPath("Field", reflect.TypeFor[fwtypes.ListNestedObjectValueOf[tfSingleStringField]](), "Fields", reflect.TypeFor[[]awsSingleStringValue]()),
traceExpandingNestedObjectCollection("Field", reflect.TypeFor[fwtypes.ListNestedObjectValueOf[tfSingleStringField]](), 1, "Fields", reflect.TypeFor[[]awsSingleStringValue]()),
traceMatchedFieldsWithPath("Field[0]", "Field1", reflect.TypeFor[tfSingleStringField](), "Fields[0]", "Field1", reflect.TypeFor[*awsSingleStringValue]()),
Expand Down
10 changes: 5 additions & 5 deletions internal/framework/flex/auto_flatten_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,16 @@ func TestFlatten(t *testing.T) {
Source: &awsPluralSliceOfNestedObjectValues{
Fields: []awsSingleStringValue{{Field1: "a"}},
},
Target: &tfListOfNestedObject2{},
WantTarget: &tfListOfNestedObject2{
Target: &tfSingluarListOfNestedObjects{},
WantTarget: &tfSingluarListOfNestedObjects{
Field: fwtypes.NewListNestedObjectValueOfPtrMust(ctx, &tfSingleStringField{
Field1: types.StringValue("a"),
}),
},
expectedLogLines: []map[string]any{
infoFlattening(reflect.TypeFor[*awsPluralSliceOfNestedObjectValues](), reflect.TypeFor[*tfListOfNestedObject2]()),
infoConverting(reflect.TypeFor[awsPluralSliceOfNestedObjectValues](), reflect.TypeFor[*tfListOfNestedObject2]()),
traceMatchedFields("Fields", reflect.TypeFor[awsPluralSliceOfNestedObjectValues](), "Field", reflect.TypeFor[*tfListOfNestedObject2]()),
infoFlattening(reflect.TypeFor[*awsPluralSliceOfNestedObjectValues](), reflect.TypeFor[*tfSingluarListOfNestedObjects]()),
infoConverting(reflect.TypeFor[awsPluralSliceOfNestedObjectValues](), reflect.TypeFor[*tfSingluarListOfNestedObjects]()),
traceMatchedFields("Fields", reflect.TypeFor[awsPluralSliceOfNestedObjectValues](), "Field", reflect.TypeFor[*tfSingluarListOfNestedObjects]()),
infoConvertingWithPath("Fields", reflect.TypeFor[[]awsSingleStringValue](), "Field", reflect.TypeFor[fwtypes.ListNestedObjectValueOf[tfSingleStringField]]()),
traceMatchedFieldsWithPath("Fields[0]", "Field1", reflect.TypeFor[awsSingleStringValue](), "Field[0]", "Field1", reflect.TypeFor[*tfSingleStringField]()),
infoConvertingWithPath("Fields[0].Field1", reflect.TypeFor[string](), "Field[0].Field1", reflect.TypeFor[types.String]()),
Expand Down
12 changes: 6 additions & 6 deletions internal/framework/flex/autoflex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ type awsComplexValue struct {
Field4 []awsSingleInt64Value
}

// tfListOfNestedObject2 testing for idiomatic singular on TF side but plural on AWS side
type tfListOfNestedObject2 struct {
// tfSingluarListOfNestedObjects testing for idiomatic singular on TF side but plural on AWS side
type tfSingluarListOfNestedObjects struct {
Field fwtypes.ListNestedObjectValueOf[tfSingleStringField] `tfsdk:"field"`
}

type awsPluralSliceOfNestedObjectValues struct {
Fields []awsSingleStringValue
}

type tfSpecialPluralization struct {
City types.List `tfsdk:"city"`
Coach types.List `tfsdk:"coach"`
Expand Down Expand Up @@ -170,10 +174,6 @@ type awsSliceOfNestedObjectValues struct {
Field1 []awsSingleStringValue
}

type awsPluralSliceOfNestedObjectValues struct {
Fields []awsSingleStringValue
}

// tfFieldNamePrefix has no prefix to test matching on prefix
type tfFieldNamePrefix struct {
Name types.String `tfsdk:"name"`
Expand Down

0 comments on commit fd39cae

Please sign in to comment.