fix(server): dynamodb tests + provider config

This commit is contained in:
Lakhan Samani
2022-10-21 15:55:54 +05:30
parent 476bdf00fc
commit 8449821d1b
7 changed files with 40 additions and 28 deletions

View File

@@ -2,6 +2,7 @@ package test
import (
"context"
"fmt"
"os"
"strings"
"testing"
@@ -20,7 +21,7 @@ func TestResolvers(t *testing.T) {
constants.DbTypeArangodb: "http://localhost:8529",
constants.DbTypeMongodb: "mongodb://localhost:27017",
constants.DbTypeScyllaDB: "127.0.0.1:9042",
constants.DbTypeDynamoDB: "http://127.0.0.1:8000",
constants.DbTypeDynamoDB: "http://0.0.0.0:8000",
}
testDBs := strings.Split(os.Getenv("TEST_DBS"), ",")
@@ -52,6 +53,12 @@ func TestResolvers(t *testing.T) {
os.Setenv(constants.EnvKeyDatabaseURL, dbURL)
os.Setenv(constants.EnvKeyDatabaseType, dbType)
os.Setenv(constants.EnvKeyDatabaseName, testDb)
if dbType == constants.DbTypeDynamoDB {
memorystore.Provider.UpdateEnvVariable(constants.EnvAwsRegion, "ap-south-1")
os.Setenv(constants.EnvAwsRegion, "ap-south-1")
}
memorystore.InitRequiredEnv()
err := db.InitDB()
@@ -61,12 +68,15 @@ func TestResolvers(t *testing.T) {
// clean the persisted config for test to use fresh config
envData, err := db.Provider.GetEnv(ctx)
if err == nil {
fmt.Println("envData", envData.ID, envData.EnvData)
if err == nil && envData.ID != "" {
envData.EnvData = ""
_, err = db.Provider.UpdateEnv(ctx, envData)
if err != nil {
t.Errorf("Error updating env: %s", err.Error())
}
} else if err != nil {
t.Errorf("Error getting env: %s", err.Error())
}
err = env.PersistEnv()
if err != nil {

View File

@@ -84,7 +84,7 @@ func testSetup() TestSetup {
testData := TestData{
Email: fmt.Sprintf("%d_authorizer_tester@yopmail.com", time.Now().Unix()),
Password: "Test@123",
WebhookEndpoint: "https://62cbc6738042b16aa7c22df2.mockapi.io/api/v1/webhook",
WebhookEndpoint: "https://62f93101e05644803533cf36.mockapi.io/authorizer/webhook",
TestWebhookEventTypes: []string{constants.UserAccessEnabledWebhookEvent, constants.UserAccessRevokedWebhookEvent, constants.UserCreatedWebhookEvent, constants.UserDeletedWebhookEvent, constants.UserLoginWebhookEvent, constants.UserSignUpWebhookEvent},
TestEmailTemplateEventTypes: []string{constants.VerificationTypeBasicAuthSignup, constants.VerificationTypeForgotPassword, constants.VerificationTypeMagicLinkLogin, constants.VerificationTypeUpdateEmail},
}