func TestMissingRequiredParameters(t *testing.T) { input := &StructShape{} req := aws.NewRequest(service, &aws.Operation{}, input, nil) aws.ValidateParameters(req) assert.Error(t, req.Error) assert.Equal(t, "InvalidParameter", req.Error.(awserr.Error).Code()) assert.Equal(t, "3 validation errors:\n- missing required parameter: RequiredList\n- missing required parameter: RequiredMap\n- missing required parameter: RequiredBool", req.Error.(awserr.Error).Message()) }
func TestNoErrors(t *testing.T) { input := &StructShape{ RequiredList: []*ConditionalStructShape{}, RequiredMap: map[string]*ConditionalStructShape{ "key1": {Name: aws.String("Name")}, "key2": {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) }
func TestNestedMissingRequiredParameters(t *testing.T) { input := &StructShape{ RequiredList: []*ConditionalStructShape{{}}, RequiredMap: map[string]*ConditionalStructShape{ "key1": {Name: aws.String("Name")}, "key2": {}, }, RequiredBool: aws.Boolean(true), OptionalStruct: &ConditionalStructShape{}, } req := aws.NewRequest(service, &aws.Operation{}, input, nil) aws.ValidateParameters(req) assert.Error(t, req.Error) assert.Equal(t, "InvalidParameter", req.Error.(awserr.Error).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", req.Error.(awserr.Error).Message()) }