Added user validation check
parent
eb2f42d50a
commit
103e1d5b4e
@ -0,0 +1,20 @@
|
|||||||
|
package ratchet
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestUserValidation(t *testing.T) {
|
||||||
|
t.Run("user should return invalid", func(t *testing.T) {
|
||||||
|
u := &User{}
|
||||||
|
if ErrorCode(u.Validate()) != EINVALID {
|
||||||
|
t.Errorf("User validation should have failed but passed instead.")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("user validation should pass", func(t *testing.T) {
|
||||||
|
u := &User{Name: "Drew"}
|
||||||
|
if u.Validate() != nil {
|
||||||
|
t.Errorf("User validation failed")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue