|
|
|
@ -6,10 +6,16 @@ import ( |
|
|
|
|
"testing" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"gopkg.in/bluesuncorp/validator.v5" |
|
|
|
|
// "gopkg.in/bluesuncorp/validator.v5"
|
|
|
|
|
"github.com/joeybloggs/validator" |
|
|
|
|
. "gopkg.in/check.v1" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// NOTES:
|
|
|
|
|
// - Run "go test" to run tests
|
|
|
|
|
// - Run "gocov test | gocov report" to report on test converage by file
|
|
|
|
|
// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called
|
|
|
|
|
|
|
|
|
|
type I interface { |
|
|
|
|
Foo() string |
|
|
|
|
} |
|
|
|
@ -137,6 +143,26 @@ func isEqualFunc(val interface{}, current interface{}, field interface{}, param |
|
|
|
|
return current.(string) == field.(string) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ms *MySuite) TestBase64Validation(c *C) { |
|
|
|
|
|
|
|
|
|
s := "dW5pY29ybg==" |
|
|
|
|
|
|
|
|
|
err := validate.Field(s, "base64") |
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
|
|
|
|
|
s = "dGhpIGlzIGEgdGVzdCBiYXNlNjQ=" |
|
|
|
|
err = validate.Field(s, "base64") |
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
|
|
|
|
|
s = "" |
|
|
|
|
err = validate.Field(s, "base64") |
|
|
|
|
c.Assert(err, NotNil) |
|
|
|
|
|
|
|
|
|
s = "dW5pY29ybg== foo bar" |
|
|
|
|
err = validate.Field(s, "base64") |
|
|
|
|
c.Assert(err, NotNil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ms *MySuite) TestStructOnlyValidation(c *C) { |
|
|
|
|
|
|
|
|
|
type Inner struct { |
|
|
|
|