mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-02-05 11:48:28 -06:00
26 lines
492 B
Go
26 lines
492 B
Go
package validate
|
|
|
|
import "testing"
|
|
|
|
func TestEmail(t *testing.T) {
|
|
tests := []struct {
|
|
email string
|
|
valid bool
|
|
}{
|
|
{"", false},
|
|
{"test", false},
|
|
{"test@", false},
|
|
{"@example.com", false},
|
|
{"test@example", false},
|
|
{"test@example.com", true},
|
|
{"test@example.com.gt", true},
|
|
}
|
|
|
|
for _, testItem := range tests {
|
|
isValid := Email(testItem.email)
|
|
if isValid != testItem.valid {
|
|
t.Errorf("Email(%s) expected %v, got %v", testItem.email, testItem.valid, isValid)
|
|
}
|
|
}
|
|
}
|