|
| 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 generate_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 TestSageMaker_ARN_Field_Override(t *testing.T) { |
| 26 | + assert := assert.New(t) |
| 27 | + require := require.New(t) |
| 28 | + |
| 29 | + g := testutil.NewGeneratorForService(t, "sagemaker") |
| 30 | + |
| 31 | + crds, err := g.GetCRDs() |
| 32 | + require.Nil(err) |
| 33 | + |
| 34 | + crd := getCRDByName("DataQualityJobDefinition", crds) |
| 35 | + require.NotNil(crd) |
| 36 | + |
| 37 | + // The CreateDataQualityJobDefinition has the following definition: |
| 38 | + // |
| 39 | + // "CreateDataQualityJobDefinition":{ |
| 40 | + // "name":"CreateDataQualityJobDefinition", |
| 41 | + // "http":{ |
| 42 | + // "method":"POST", |
| 43 | + // "requestUri":"/" |
| 44 | + // }, |
| 45 | + // "input":{"shape":"CreateDataQualityJobDefinitionRequest"}, |
| 46 | + // "output":{"shape":"CreateDataQualityJobDefinitionResponse"}, |
| 47 | + // "errors":[ |
| 48 | + // {"shape":"ResourceLimitExceeded"}, |
| 49 | + // {"shape":"ResourceInUse"} |
| 50 | + // ] |
| 51 | + // } |
| 52 | + // |
| 53 | + // Where the CreateDataQualityJobDefinitionResponse shape looks like this: |
| 54 | + // |
| 55 | + // "CreateDataQualityJobDefinitionResponse":{ |
| 56 | + // "type":"structure", |
| 57 | + // "required":["JobDefinitionArn"], |
| 58 | + // "members":{ |
| 59 | + // "JobDefinitionArn":{"shape":"MonitoringJobDefinitionArn"} |
| 60 | + // } |
| 61 | + // } |
| 62 | + // |
| 63 | + // So, we expect that the logic in crd.IsPrimaryARNField() parses through |
| 64 | + // field config and identifies the JobDefinitionArn as the primaryARNField |
| 65 | + // for the resource |
| 66 | + assert.Equal(true, crd.IsPrimaryARNField("JobDefinitionArn")) |
| 67 | + |
| 68 | +} |
0 commit comments