mirror of
https://github.com/cubixle/email-checker.git
synced 2026-04-24 21:24:41 +01:00
added isGeneric method and tests
This commit is contained in:
53
checker_test.go
Normal file
53
checker_test.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package checker_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lukerodham/email-checker"
|
||||
)
|
||||
|
||||
func TestIsGeneric(t *testing.T) {
|
||||
tests := []struct {
|
||||
Email string
|
||||
IsGeneric bool
|
||||
ShouldError bool
|
||||
}{
|
||||
{
|
||||
Email: "example@gmail.com",
|
||||
IsGeneric: true,
|
||||
ShouldError: false,
|
||||
},
|
||||
{
|
||||
Email: "example@hotmail.com",
|
||||
IsGeneric: true,
|
||||
ShouldError: false,
|
||||
},
|
||||
{
|
||||
Email: "example@yahoo.com",
|
||||
IsGeneric: true,
|
||||
ShouldError: false,
|
||||
},
|
||||
{
|
||||
Email: "example@google.com",
|
||||
IsGeneric: false,
|
||||
ShouldError: false,
|
||||
},
|
||||
{
|
||||
Email: "yahoo.com",
|
||||
IsGeneric: false,
|
||||
ShouldError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
is, err := checker.IsGeneric(test.Email)
|
||||
|
||||
if err != nil && test.ShouldError == false {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if test.IsGeneric != is {
|
||||
t.Errorf("expect %v to equal %v", test.IsGeneric, is)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user