Skip to content

Commit c651d2b

Browse files
authored
Align EC2 testdata models with go.mod (#333)
Issue #, if available: N/A, it is difficult to enhance code-generator+unit test, then compare results with `make build-controller` when models used by unit tests and the application differ Description of changes: * Updates EC2's testdata api models/shapes to align with the model version used by code-generator * Updates EC2 unit tests By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent d3223a7 commit c651d2b

File tree

7 files changed

+11778
-1140
lines changed

7 files changed

+11778
-1140
lines changed

pkg/generate/code/resource_reference_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ func Test_ReferenceFieldsPresent_NestedSliceOfStructsReference(t *testing.T) {
182182
require.NotNil(crd)
183183
expected :=
184184
`if ko.Spec.Routes != nil {
185-
for _, iter32 := range ko.Spec.Routes {
186-
if iter32.GatewayRef != nil {
185+
for _, iter35 := range ko.Spec.Routes {
186+
if iter35.GatewayRef != nil {
187187
return true
188188
}
189189
}
190190
}
191191
if ko.Spec.Routes != nil {
192-
for _, iter35 := range ko.Spec.Routes {
193-
if iter35.NATGatewayRef != nil {
192+
for _, iter38 := range ko.Spec.Routes {
193+
if iter38.NATGatewayRef != nil {
194194
return true
195195
}
196196
}

pkg/generate/code/set_resource_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,6 +3066,22 @@ func TestSetResource_EC2_SecurityGroups_SetResourceIdentifiers(t *testing.T) {
30663066
} else {
30673067
ko.Status.ID = nil
30683068
}
3069+
if resp.Tags != nil {
3070+
f1 := []*svcapitypes.Tag{}
3071+
for _, f1iter := range resp.Tags {
3072+
f1elem := &svcapitypes.Tag{}
3073+
if f1iter.Key != nil {
3074+
f1elem.Key = f1iter.Key
3075+
}
3076+
if f1iter.Value != nil {
3077+
f1elem.Value = f1iter.Value
3078+
}
3079+
f1 = append(f1, f1elem)
3080+
}
3081+
ko.Status.Tags = f1
3082+
} else {
3083+
ko.Status.Tags = nil
3084+
}
30693085
`
30703086
assert.Equal(
30713087
expected,

pkg/generate/code/set_sdk_test.go

Lines changed: 341 additions & 126 deletions
Large diffs are not rendered by default.

pkg/model/model_ec2_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ import (
1717
"strings"
1818
"testing"
1919

20-
"github.com/aws-controllers-k8s/code-generator/pkg/model"
21-
2220
"github.com/stretchr/testify/assert"
2321
"github.com/stretchr/testify/require"
2422

23+
"github.com/aws-controllers-k8s/code-generator/pkg/model"
2524
"github.com/aws-controllers-k8s/code-generator/pkg/testutil"
2625
)
2726

@@ -126,6 +125,7 @@ func TestEC2_Volume(t *testing.T) {
126125

127126
expSpecFieldCamel := []string{
128127
"AvailabilityZone",
128+
"ClientToken",
129129
"DryRun",
130130
"Encrypted",
131131
"IOPS",
@@ -135,6 +135,7 @@ func TestEC2_Volume(t *testing.T) {
135135
"Size",
136136
"SnapshotID",
137137
"TagSpecifications",
138+
"Throughput",
138139
"VolumeType",
139140
}
140141
assert.Equal(expSpecFieldCamel, attrCamelNames(specFields))

0 commit comments

Comments
 (0)