mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
Space API (#290)
This commit is contained in:
67
email/handler/email_test.go
Normal file
67
email/handler/email_test.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestEmailValidation(t *testing.T) {
|
||||
g := NewWithT(t)
|
||||
tcs := []struct {
|
||||
name string
|
||||
email string
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
name: "Empty",
|
||||
email: "",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "Normal email",
|
||||
email: "joe@example.com",
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Email with dots",
|
||||
email: "joe.bloggs@example.com",
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Email with plus",
|
||||
email: "joe+1@example.com",
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "Email with underscores",
|
||||
email: "joe_bloggs@example.com",
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
name: "White space",
|
||||
email: "joe bloggs@example.com",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "Trailing whitespace",
|
||||
email: "joe@example.com ",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "Preceding whitespace",
|
||||
email: " joe@example.com",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
name: "Normal email",
|
||||
email: "joe@example.com",
|
||||
valid: true,
|
||||
},
|
||||
}
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
g.Expect(validEmail(tc.email)).To(Equal(tc.valid))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user