1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/model/user_test.go
2017-07-17 00:01:35 -04:00

47 lines
759 B
Go

package model
import "testing"
func TestUserValidate(t *testing.T) {
var tests = []struct {
user User
err error
}{
{
user: User{},
err: errUserLoginInvalid,
},
{
user: User{Login: "octocat!"},
err: errUserLoginInvalid,
},
{
user: User{Login: "!octocat"},
err: errUserLoginInvalid,
},
{
user: User{Login: "john$smith"},
err: errUserLoginInvalid,
},
{
user: User{Login: "octocat"},
err: nil,
},
{
user: User{Login: "john-smith"},
err: nil,
},
{
user: User{Login: "john_smith"},
err: nil,
},
}
for _, test := range tests {
err := test.user.Validate()
if want, got := test.err, err; want != got {
t.Errorf("Want user validation error %s, got %s", want, got)
}
}
}