예제 #1
0
func TestMissingRequiredParameters(t *testing.T) {
	input := &StructShape{}
	req := aws.NewRequest(service, &aws.Operation{}, input, nil)
	aws.ValidateParameters(req)
	err := aws.Error(req.Error)

	assert.Error(t, err)
	assert.Equal(t, "InvalidParameter", err.Code)
	assert.Equal(t, "3 validation errors:\n- missing required parameter: RequiredList\n- missing required parameter: RequiredMap\n- missing required parameter: RequiredBool", err.Message)
}
예제 #2
0
func TestNoErrors(t *testing.T) {
	input := &StructShape{
		RequiredList: []*ConditionalStructShape{},
		RequiredMap: &map[string]*ConditionalStructShape{
			"key1": &ConditionalStructShape{Name: aws.String("Name")},
			"key2": &ConditionalStructShape{Name: aws.String("Name")},
		},
		RequiredBool:   aws.Boolean(true),
		OptionalStruct: &ConditionalStructShape{Name: aws.String("Name")},
	}

	req := aws.NewRequest(service, &aws.Operation{}, input, nil)
	aws.ValidateParameters(req)
	assert.NoError(t, req.Error)
}
예제 #3
0
func TestNestedMissingRequiredParameters(t *testing.T) {
	input := &StructShape{
		RequiredList: []*ConditionalStructShape{&ConditionalStructShape{}},
		RequiredMap: &map[string]*ConditionalStructShape{
			"key1": &ConditionalStructShape{Name: aws.String("Name")},
			"key2": &ConditionalStructShape{},
		},
		RequiredBool:   aws.Boolean(true),
		OptionalStruct: &ConditionalStructShape{},
	}

	req := aws.NewRequest(service, &aws.Operation{}, input, nil)
	aws.ValidateParameters(req)
	err := aws.Error(req.Error)

	assert.Error(t, err)
	assert.Equal(t, "InvalidParameter", err.Code)
	assert.Equal(t, "3 validation errors:\n- missing required parameter: RequiredList[0].Name\n- missing required parameter: RequiredMap[\"key2\"].Name\n- missing required parameter: OptionalStruct.Name", err.Message)

}