fix: tests

This commit is contained in:
Lakhan Samani
2022-04-22 19:56:55 +05:30
parent aaf0831793
commit 961f2271c1
9 changed files with 94 additions and 27 deletions

View File

@@ -15,9 +15,9 @@ import (
func enableAccessTest(t *testing.T, s TestSetup) {
t.Helper()
t.Run(`should revoke access`, func(t *testing.T) {
t.Run(`should enable access`, func(t *testing.T) {
req, ctx := createContext(s)
email := "revoke_access." + s.TestInfo.Email
email := "enable_access." + s.TestInfo.Email
_, err := resolvers.MagicLinkLoginResolver(ctx, model.MagicLinkLoginInput{
Email: email,
})
@@ -45,7 +45,7 @@ func enableAccessTest(t *testing.T, s TestSetup) {
assert.NoError(t, err)
assert.NotEmpty(t, res.Message)
// it should allow login with revoked access
// it should allow login with enabled access
res, err = resolvers.MagicLinkLoginResolver(ctx, model.MagicLinkLoginInput{
Email: email,
})

View File

@@ -14,6 +14,7 @@ func TestResolvers(t *testing.T) {
constants.DbTypeSqlite: "../../data.db",
// constants.DbTypeArangodb: "http://localhost:8529",
// constants.DbTypeMongodb: "mongodb://localhost:27017",
// constants.DbTypeCassandraDB: "127.0.0.1:9042",
}
for dbType, dbURL := range databases {

View File

@@ -46,6 +46,11 @@ func cleanData(email string) {
err = db.Provider.DeleteVerificationRequest(verificationRequest)
}
verificationRequest, err = db.Provider.GetVerificationRequestByEmail(email, constants.VerificationTypeMagicLinkLogin)
if err == nil {
err = db.Provider.DeleteVerificationRequest(verificationRequest)
}
dbUser, err := db.Provider.GetUserByEmail(email)
if err == nil {
db.Provider.DeleteUser(dbUser)