Skip to content

Commit 02eb1d6

Browse files
committed
fix: add const for test env
1 parent 78a673e commit 02eb1d6

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

server/constants/env.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package constants
33
var VERSION = "0.0.1"
44

55
const (
6+
// TestEnv is used for testing
7+
TestEnv = "test"
68
// EnvKeyEnv key for env variable ENV
79
EnvKeyEnv = "ENV"
810
// EnvKeyEnvPath key for cli arg variable ENV_PATH

server/email/email.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func SendMail(to []string, Subject, bodyMessage string) error {
3737
if err != nil {
3838
return err
3939
}
40-
if envKey == "test" {
40+
if envKey == constants.TestEnv {
4141
return nil
4242
}
4343
m := gomail.NewMessage()

server/memorystore/providers/inmemory/envstore.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package inmemory
33
import (
44
"os"
55
"sync"
6+
7+
"github.com/authorizerdev/authorizer/server/constants"
68
)
79

810
// EnvStore struct to store the env variables
@@ -13,7 +15,7 @@ type EnvStore struct {
1315

1416
// UpdateEnvStore to update the whole env store object
1517
func (e *EnvStore) UpdateStore(store map[string]interface{}) {
16-
if os.Getenv("ENV") != "test" {
18+
if os.Getenv("ENV") != constants.TestEnv {
1719
e.mutex.Lock()
1820
defer e.mutex.Unlock()
1921
}
@@ -36,7 +38,7 @@ func (e *EnvStore) Get(key string) interface{} {
3638

3739
// Set sets the value of the key in env store
3840
func (e *EnvStore) Set(key string, value interface{}) {
39-
if os.Getenv("ENV") != "test" {
41+
if os.Getenv("ENV") != constants.TestEnv {
4042
e.mutex.Lock()
4143
defer e.mutex.Unlock()
4244
}

server/memorystore/providers/inmemory/store.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import (
44
"fmt"
55
"os"
66
"strings"
7+
8+
"github.com/authorizerdev/authorizer/server/constants"
79
)
810

911
// ClearStore clears the in-memory store.
1012
func (c *provider) ClearStore() error {
11-
if os.Getenv("ENV") != "test" {
13+
if os.Getenv("ENV") != constants.TestEnv {
1214
c.mutex.Lock()
1315
defer c.mutex.Unlock()
1416
}
@@ -32,7 +34,7 @@ func (c *provider) GetUserSessions(userId string) map[string]string {
3234

3335
// DeleteAllUserSession deletes all the user sessions from in-memory store.
3436
func (c *provider) DeleteAllUserSession(userId string) error {
35-
if os.Getenv("ENV") != "test" {
37+
if os.Getenv("ENV") != constants.TestEnv {
3638
c.mutex.Lock()
3739
defer c.mutex.Unlock()
3840
}
@@ -46,7 +48,7 @@ func (c *provider) DeleteAllUserSession(userId string) error {
4648

4749
// SetState sets the state in the in-memory store.
4850
func (c *provider) SetState(key, state string) error {
49-
if os.Getenv("ENV") != "test" {
51+
if os.Getenv("ENV") != constants.TestEnv {
5052
c.mutex.Lock()
5153
defer c.mutex.Unlock()
5254
}
@@ -67,7 +69,7 @@ func (c *provider) GetState(key string) (string, error) {
6769

6870
// RemoveState removes the state from the in-memory store.
6971
func (c *provider) RemoveState(key string) error {
70-
if os.Getenv("ENV") != "test" {
72+
if os.Getenv("ENV") != constants.TestEnv {
7173
c.mutex.Lock()
7274
defer c.mutex.Unlock()
7375
}

0 commit comments

Comments
 (0)