test: add email validtor test
This commit is contained in:
parent
c3f4cd3bf9
commit
e0a77da773
|
@ -4,11 +4,10 @@ go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/99designs/gqlgen v0.13.0
|
github.com/99designs/gqlgen v0.13.0
|
||||||
github.com/arangodb/go-driver v1.2.1 // indirect
|
github.com/arangodb/go-driver v1.2.1
|
||||||
github.com/coreos/go-oidc/v3 v3.1.0 // indirect
|
github.com/coreos/go-oidc/v3 v3.1.0
|
||||||
github.com/gin-contrib/location v0.0.2 // indirect
|
github.com/gin-contrib/location v0.0.2
|
||||||
github.com/gin-gonic/gin v1.7.2
|
github.com/gin-gonic/gin v1.7.2
|
||||||
github.com/go-kit/kit v0.10.0 // indirect
|
|
||||||
github.com/go-playground/validator/v10 v10.8.0 // indirect
|
github.com/go-playground/validator/v10 v10.8.0 // indirect
|
||||||
github.com/go-redis/redis/v8 v8.11.0
|
github.com/go-redis/redis/v8 v8.11.0
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||||
|
@ -17,7 +16,10 @@ require (
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/json-iterator/go v1.1.11 // indirect
|
github.com/json-iterator/go v1.1.11 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.13 // indirect
|
github.com/mattn/go-isatty v0.0.13 // indirect
|
||||||
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f // indirect
|
github.com/mitchellh/mapstructure v1.1.2 // indirect
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||||
|
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f
|
||||||
github.com/ugorji/go v1.2.6 // indirect
|
github.com/ugorji/go v1.2.6 // indirect
|
||||||
github.com/vektah/gqlparser/v2 v2.1.0
|
github.com/vektah/gqlparser/v2 v2.1.0
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||||
|
@ -29,6 +31,6 @@ require (
|
||||||
gorm.io/driver/mysql v1.2.1
|
gorm.io/driver/mysql v1.2.1
|
||||||
gorm.io/driver/postgres v1.2.3
|
gorm.io/driver/postgres v1.2.3
|
||||||
gorm.io/driver/sqlite v1.2.6
|
gorm.io/driver/sqlite v1.2.6
|
||||||
gorm.io/driver/sqlserver v1.2.1 // indirect
|
gorm.io/driver/sqlserver v1.2.1
|
||||||
gorm.io/gorm v1.22.4
|
gorm.io/gorm v1.22.4
|
||||||
)
|
)
|
||||||
|
|
513
server/go.sum
513
server/go.sum
File diff suppressed because it is too large
Load Diff
21
server/utils/validator_test.go
Normal file
21
server/utils/validator_test.go
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestIsValidEmail(t *testing.T) {
|
||||||
|
validEmail := "lakhan@gmail.com"
|
||||||
|
invalidEmail1 := "lakhan"
|
||||||
|
invalidEmail2 := "lakhan.me"
|
||||||
|
|
||||||
|
if IsValidEmail(validEmail) != true {
|
||||||
|
t.Errorf("IsValidEmail Test failed got %t, wanted %t for %s", false, true, validEmail)
|
||||||
|
}
|
||||||
|
|
||||||
|
if IsValidEmail(invalidEmail1) != false {
|
||||||
|
t.Errorf("IsValidEmail Test failed got %t, wanted %t for %s", true, false, invalidEmail1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if IsValidEmail(invalidEmail2) != false {
|
||||||
|
t.Errorf("IsValidEmail Test failed got %t, wanted %t for %s", true, false, invalidEmail2)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user