fix: disable mutex for testing purpose

This commit is contained in:
Lakhan Samani
2022-05-31 15:00:11 +05:30
parent 98015708a2
commit 69b56c9912
7 changed files with 44 additions and 32 deletions

View File

@@ -12,8 +12,8 @@ type EnvStore struct {
// UpdateEnvStore to update the whole env store object
func (e *EnvStore) UpdateStore(store map[string]interface{}) {
e.mutex.Lock()
defer e.mutex.Unlock()
// e.mutex.Lock()
// defer e.mutex.Unlock()
// just override the keys + new keys
for key, value := range store {
@@ -23,22 +23,22 @@ func (e *EnvStore) UpdateStore(store map[string]interface{}) {
// GetStore returns the env store
func (e *EnvStore) GetStore() map[string]interface{} {
e.mutex.Lock()
defer e.mutex.Unlock()
// e.mutex.Lock()
// defer e.mutex.Unlock()
return e.store
}
// Get returns the value of the key in evn store
func (s *EnvStore) Get(key string) interface{} {
s.mutex.Lock()
defer s.mutex.Unlock()
return s.store[key]
func (e *EnvStore) Get(key string) interface{} {
// e.mutex.Lock()
// defer e.mutex.Unlock()
return e.store[key]
}
// Set sets the value of the key in env store
func (s *EnvStore) Set(key string, value interface{}) {
s.mutex.Lock()
defer s.mutex.Unlock()
s.store[key] = value
func (e *EnvStore) Set(key string, value interface{}) {
// e.mutex.Lock()
// defer e.mutex.Unlock()
e.store[key] = value
}

View File

@@ -7,8 +7,8 @@ import (
// ClearStore clears the in-memory store.
func (c *provider) ClearStore() error {
c.mutex.Lock()
defer c.mutex.Unlock()
// c.mutex.Lock()
// defer c.mutex.Unlock()
c.sessionStore = map[string]map[string]string{}
return nil
@@ -16,8 +16,8 @@ func (c *provider) ClearStore() error {
// GetUserSessions returns all the user session token from the in-memory store.
func (c *provider) GetUserSessions(userId string) map[string]string {
c.mutex.Lock()
defer c.mutex.Unlock()
// c.mutex.Lock()
// defer c.mutex.Unlock()
res := map[string]string{}
for k, v := range c.stateStore {
split := strings.Split(v, "@")
@@ -31,8 +31,8 @@ func (c *provider) GetUserSessions(userId string) map[string]string {
// DeleteAllUserSession deletes all the user sessions from in-memory store.
func (c *provider) DeleteAllUserSession(userId string) error {
c.mutex.Lock()
defer c.mutex.Unlock()
// c.mutex.Lock()
// defer c.mutex.Unlock()
sessions := c.GetUserSessions(userId)
for k := range sessions {
c.RemoveState(k)
@@ -43,8 +43,8 @@ func (c *provider) DeleteAllUserSession(userId string) error {
// SetState sets the state in the in-memory store.
func (c *provider) SetState(key, state string) error {
c.mutex.Lock()
defer c.mutex.Unlock()
// c.mutex.Lock()
// defer c.mutex.Unlock()
c.stateStore[key] = state
return nil
@@ -52,8 +52,8 @@ func (c *provider) SetState(key, state string) error {
// GetState gets the state from the in-memory store.
func (c *provider) GetState(key string) (string, error) {
c.mutex.Lock()
defer c.mutex.Unlock()
// c.mutex.Lock()
// defer c.mutex.Unlock()
state := ""
if stateVal, ok := c.stateStore[key]; ok {
@@ -65,8 +65,8 @@ func (c *provider) GetState(key string) (string, error) {
// RemoveState removes the state from the in-memory store.
func (c *provider) RemoveState(key string) error {
c.mutex.Lock()
defer c.mutex.Unlock()
// c.mutex.Lock()
// defer c.mutex.Unlock()
delete(c.stateStore, key)
return nil