Skip to content

Commit 709a1e1

Browse files
authored
Add unit tests to common_test (#178)
Issue #, if available: [#922](aws-controllers-k8s/community#922) Description of changes: * Increasing test coverage of identifier helpers By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 6f22b7b commit 709a1e1

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

pkg/generate/code/common_test.go

+49
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,53 @@ func TestGetIdentifiers_APIGatewayV2_API_Multiple(t *testing.T) {
106106
actualIdentifiers := crd.GetIdentifiers()
107107
assert.Len(actualIdentifiers, 2)
108108
assert.True(ackcompare.SliceStringEqual(expIdentifiers, actualIdentifiers))
109+
}
110+
111+
func TestFindARNIdentifiersInShape_SNS_Topic_GetAttributes(t *testing.T) {
112+
assert := assert.New(t)
113+
require := require.New(t)
114+
115+
g := testutil.NewModelForService(t, "sns")
116+
crd := testutil.GetCRDByName(t, g, "Topic")
117+
require.NotNil(crd)
118+
119+
expIdentifiers := []string{"TopicArn"}
120+
actualIdentifiers := code.FindARNIdentifiersInShape(crd,
121+
crd.Ops.GetAttributes.InputRef.Shape)
122+
123+
assert.True(ackcompare.SliceStringEqual(expIdentifiers, actualIdentifiers))
124+
}
125+
126+
func TestFindPluralizedIdentifiersInShape_EC2_VPC_ReadMany(t *testing.T) {
127+
assert := assert.New(t)
128+
require := require.New(t)
129+
130+
g := testutil.NewModelForService(t, "ec2")
131+
crd := testutil.GetCRDByName(t, g, "Vpc")
132+
require.NotNil(crd)
133+
134+
expModelIdentifier := "VpcId"
135+
expShapeIdentifier := "VpcIds"
136+
crIdentifier, shapeIdentifier := code.FindPluralizedIdentifiersInShape(crd,
137+
crd.Ops.ReadMany.InputRef.Shape)
138+
139+
assert.Equal(expModelIdentifier, crIdentifier)
140+
assert.Equal(expShapeIdentifier, shapeIdentifier)
141+
}
142+
143+
func TestFindPrimaryIdentifierFieldNames_APIGatewayV2_API_ReadOne(t *testing.T) {
144+
assert := assert.New(t)
145+
require := require.New(t)
146+
147+
g := testutil.NewModelForService(t, "apigatewayv2")
148+
crd := testutil.GetCRDByName(t, g, "Api")
149+
require.NotNil(crd)
150+
151+
expModelIdentifier := "ApiId"
152+
expShapeIdentifier := "ApiId"
153+
crIdentifier, shapeIdentifier := code.FindPrimaryIdentifierFieldNames(
154+
crd.Config(), crd, crd.Ops.ReadOne)
155+
156+
assert.Equal(expModelIdentifier, crIdentifier)
157+
assert.Equal(expShapeIdentifier, shapeIdentifier)
109158
}

0 commit comments

Comments
 (0)