Space API (#290)

This commit is contained in:
Dominic Wong
2021-12-09 10:56:42 +00:00
committed by GitHub
parent bed010d0a9
commit c61badab4b
13 changed files with 2126 additions and 109 deletions

View 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))
})
}
}