|
| 1 | +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"). You may |
| 4 | +// not use this file except in compliance with the License. A copy of the |
| 5 | +// License is located at |
| 6 | +// |
| 7 | +// http://aws.amazon.com/apache2.0/ |
| 8 | +// |
| 9 | +// or in the "license" file accompanying this file. This file is distributed |
| 10 | +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 | +// express or implied. See the License for the specific language governing |
| 12 | +// permissions and limitations under the License. |
| 13 | + |
| 14 | +package model_test |
| 15 | + |
| 16 | +import ( |
| 17 | + "testing" |
| 18 | + |
| 19 | + "github.com/stretchr/testify/assert" |
| 20 | + "github.com/stretchr/testify/require" |
| 21 | + |
| 22 | + "github.com/aws-controllers-k8s/code-generator/pkg/testutil" |
| 23 | +) |
| 24 | + |
| 25 | +func TestRoute53_RecordSet(t *testing.T) { |
| 26 | + assert := assert.New(t) |
| 27 | + require := require.New(t) |
| 28 | + |
| 29 | + g := testutil.NewModelForService(t, "route53") |
| 30 | + |
| 31 | + crds, err := g.GetCRDs() |
| 32 | + require.Nil(err) |
| 33 | + |
| 34 | + crd := getCRDByName("RecordSet", crds) |
| 35 | + require.NotNil(crd) |
| 36 | + |
| 37 | + assert.Equal("RecordSet", crd.Names.Camel) |
| 38 | + assert.Equal("recordSet", crd.Names.CamelLower) |
| 39 | + assert.Equal("record_set", crd.Names.Snake) |
| 40 | + |
| 41 | + // The Route53 API has CD as one operation +L: |
| 42 | + // |
| 43 | + // * ChangeResourceRecordSets |
| 44 | + // * ChangeResourceRecordSets |
| 45 | + // * ListResourceRecordSets |
| 46 | + require.NotNil(crd.Ops) |
| 47 | + |
| 48 | + assert.NotNil(crd.Ops.Create) |
| 49 | + assert.NotNil(crd.Ops.ReadMany) |
| 50 | + assert.NotNil(crd.Ops.Delete) |
| 51 | + |
| 52 | + // But sadly, has no Update or ReadOne operation :( |
| 53 | + // for update we still use ChangeResourceRecordSets |
| 54 | + assert.Nil(crd.Ops.ReadOne) |
| 55 | + assert.Nil(crd.Ops.Update) |
| 56 | + |
| 57 | + specFields := crd.SpecFields |
| 58 | + statusFields := crd.StatusFields |
| 59 | + |
| 60 | + expSpecFieldCamel := []string{ |
| 61 | + "AliasTarget", |
| 62 | + // "ChangeBatch", <= Testing that this is removed from spec |
| 63 | + "CIDRRoutingConfig", |
| 64 | + "Failover", |
| 65 | + "GeoLocation", |
| 66 | + "HealthCheckID", |
| 67 | + "HostedZoneID", |
| 68 | + "HostedZoneRef", |
| 69 | + "MultiValueAnswer", |
| 70 | + "Name", |
| 71 | + "RecordType", |
| 72 | + "Region", |
| 73 | + "ResourceRecords", |
| 74 | + "SetIdentifier", |
| 75 | + "TTL", |
| 76 | + "Weight", |
| 77 | + } |
| 78 | + assert.Equal(expSpecFieldCamel, attrCamelNames(specFields)) |
| 79 | + |
| 80 | + expStatusFieldCamel := []string{ |
| 81 | + // There are a set of Attribute map keys that are readonly |
| 82 | + // fields... |
| 83 | + // "CreatedTimestamp", |
| 84 | + // "LastModifiedTimestamp", |
| 85 | + // There is only a QueueURL field returned from CreateQueueResult shape |
| 86 | + "ID", |
| 87 | + "Status", |
| 88 | + "SubmittedAt", |
| 89 | + } |
| 90 | + assert.Equal(expStatusFieldCamel, attrCamelNames(statusFields)) |
| 91 | +} |
0 commit comments