Skip to content

Commit cb1bbe6

Browse files
committed
Add unit tests
1 parent c575f22 commit cb1bbe6

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

pkg/generate/sagemaker_test.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,89 @@ func TestSageMaker_Error_Suffix_Message(t *testing.T) {
140140
// Validation Exception has suffix ModelPackageGroup arn:aws:sagemaker:/ does not exist
141141
assert.Equal("&& strings.HasSuffix(awsErr.Message(), \"does not exist.\") ", code.CheckExceptionMessage(crd.Config(), crd, 404))
142142
}
143+
144+
func TestSageMaker_RequeueOnSuccessSeconds(t *testing.T) {
145+
assert := assert.New(t)
146+
require := require.New(t)
147+
148+
g := testutil.NewGeneratorForService(t, "sagemaker")
149+
150+
crds, err := g.GetCRDs()
151+
require.Nil(err)
152+
153+
crd := getCRDByName("Endpoint", crds)
154+
require.NotNil(crd)
155+
156+
// The CreateEndpoint has the following definition:
157+
//
158+
// "CreateEndpoint":{
159+
// "name":"CreateEndpoint",
160+
// "http":{
161+
// "method":"POST",
162+
// "requestUri":"/"
163+
// },
164+
// "input":{"shape":"CreateEndpointInput"},
165+
// "output":{"shape":"CreateEndpointOutput"},
166+
// "errors":[
167+
// {"shape":"ResourceLimitExceeded"}
168+
// ]
169+
// }
170+
//
171+
// Where the CreateEndpointOutput shape looks like this:
172+
//
173+
// "CreateEndpointOutput":{
174+
// "type":"structure",
175+
// "required":["EndpointArn"],
176+
// "members":{
177+
// "EndpointArn":{"shape":"EndpointArn"}
178+
// }
179+
// }
180+
//
181+
// So, we expect that crd.ReconcileRequeuOnSuccessSeconds() returns the requeue
182+
// duration specified in the config file
183+
assert.Equal(10, crd.ReconcileRequeuOnSuccessSeconds())
184+
}
185+
186+
func TestSageMaker_RequeueOnSuccessSeconds_Default(t *testing.T) {
187+
assert := assert.New(t)
188+
require := require.New(t)
189+
190+
g := testutil.NewGeneratorForService(t, "sagemaker")
191+
192+
crds, err := g.GetCRDs()
193+
require.Nil(err)
194+
195+
crd := getCRDByName("DataQualityJobDefinition", crds)
196+
require.NotNil(crd)
197+
198+
// The CreateDataQualityJobDefinition has the following definition:
199+
//
200+
// "CreateDataQualityJobDefinition":{
201+
// "name":"CreateDataQualityJobDefinition",
202+
// "http":{
203+
// "method":"POST",
204+
// "requestUri":"/"
205+
// },
206+
// "input":{"shape":"CreateDataQualityJobDefinitionRequest"},
207+
// "output":{"shape":"CreateDataQualityJobDefinitionResponse"},
208+
// "errors":[
209+
// {"shape":"ResourceLimitExceeded"},
210+
// {"shape":"ResourceInUse"}
211+
// ]
212+
// }
213+
//
214+
// Where the CreateDataQualityJobDefinitionResponse shape looks like this:
215+
//
216+
// "CreateDataQualityJobDefinitionResponse":{
217+
// "type":"structure",
218+
// "required":["JobDefinitionArn"],
219+
// "members":{
220+
// "JobDefinitionArn":{"shape":"MonitoringJobDefinitionArn"}
221+
// }
222+
// }
223+
//
224+
// So, we expect that crd.ReconcileRequeuOnSuccessSeconds() returns the default
225+
// requeue duration of 0 because it is not specified in the config file
226+
assert.Equal(0, crd.ReconcileRequeuOnSuccessSeconds())
227+
228+
}

pkg/generate/testdata/models/apis/sagemaker/0000-00-00/generator.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ resources:
1919
404:
2020
code: ValidationException
2121
message_suffix: does not exist.
22+
Endpoint:
23+
reconcile:
24+
requeue_on_success_seconds: 10
2225
ignore:
2326
resource_names:
2427
- Algorithm
@@ -35,7 +38,7 @@ ignore:
3538
- Domain
3639
- EdgePackagingJob
3740
- EndpointConfig
38-
- Endpoint
41+
# - Endpoint
3942
- Experiment
4043
- FeatureGroup
4144
- FlowDefinition

0 commit comments

Comments
 (0)