updated coverage tests to be 100%

pull/108/head
joeybloggs 10 years ago
parent e1fd32247f
commit 9d2b8ee9d4
  1. 17
      validator_test.go

@ -231,6 +231,18 @@ func AssertMapFieldError(t *testing.T, s map[string]*FieldError, field string, e
EqualSkip(t, 2, val.Tag, expectedTag) EqualSkip(t, 2, val.Tag, expectedTag)
} }
func TestBadKeyValidation(t *testing.T) {
type Test struct {
Name string `validate:"required, "`
}
tst := &Test{
Name: "test",
}
PanicMatches(t, func() { validate.Struct(tst) }, "Invalid validation tag on field Name")
}
func TestFlattenValidation(t *testing.T) { func TestFlattenValidation(t *testing.T) {
type Inner struct { type Inner struct {
@ -623,9 +635,12 @@ func TestInterfaceErrValidation(t *testing.T) {
func TestMapDiveValidation(t *testing.T) { func TestMapDiveValidation(t *testing.T) {
n := map[int]interface{}{0: nil}
err := validate.Field(n, "omitempty,required")
m := map[int]string{0: "ok", 3: "", 4: "ok"} m := map[int]string{0: "ok", 3: "", 4: "ok"}
err := validate.Field(m, "len=3,dive,required") err = validate.Field(m, "len=3,dive,required")
NotEqual(t, err, nil) NotEqual(t, err, nil)
Equal(t, err.IsPlaceholderErr, true) Equal(t, err.IsPlaceholderErr, true)
Equal(t, err.IsMap, true) Equal(t, err.IsMap, true)

Loading…
Cancel
Save