Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code #123

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions test_redis_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"time"
)

//TestRedisClient is a mock for redis
// TestRedisClient is a mock for redis
type TestRedisClient struct {
store sync.Map
ttl sync.Map
}

var lock sync.Mutex

//NewTestRedisClient returns a NewTestRedisClient
// NewTestRedisClient returns a NewTestRedisClient
func NewTestRedisClient() *TestRedisClient {
return &TestRedisClient{}
}
Expand Down Expand Up @@ -57,7 +57,7 @@ func (client *TestRedisClient) Get(key string) (string, error) {
return "nil", nil
}

//Del removes the specified key. A key is ignored if it does not exist.
// Del removes the specified key. A key is ignored if it does not exist.
func (client *TestRedisClient) Del(key string) (affected int64, err error) {

_, found := client.store.Load(key)
Expand Down Expand Up @@ -129,9 +129,9 @@ func (client *TestRedisClient) LPush(key string, value ...string) (total int64,
return int64(len(list)) + 1, nil
}

//LLen returns the length of the list stored at key.
//If key does not exist, it is interpreted as an empty list and 0 is returned.
//An error is returned when the value stored at key is not a list.
// LLen returns the length of the list stored at key.
// If key does not exist, it is interpreted as an empty list and 0 is returned.
// An error is returned when the value stored at key is not a list.
func (client *TestRedisClient) LLen(key string) (affected int64, err error) {
list, err := client.findList(key)

Expand Down Expand Up @@ -347,12 +347,12 @@ func (client *TestRedisClient) FlushDb() error {
return nil
}

//storeSet stores a set
// storeSet stores a set
func (client *TestRedisClient) storeSet(key string, set map[string]struct{}) {
client.store.Store(key, set)
}

//findSet finds a set
// findSet finds a set
func (client *TestRedisClient) findSet(key string) (map[string]struct{}, error) {
//Lookup the store for the list
storedValue, found := client.store.Load(key)
Expand All @@ -371,14 +371,14 @@ func (client *TestRedisClient) findSet(key string) (map[string]struct{}, error)
return make(map[string]struct{}), nil
}

//storeList is an helper function so others don't have to deal with pointers
// storeList is an helper function so others don't have to deal with pointers
func (client *TestRedisClient) storeList(key string, list []string) {
client.store.Store(key, &list)
}

//findList returns the list stored at key.
//if key doesn't exist, an empty list is returned
//an error is returned when the value at key isn't a list
// findList returns the list stored at key.
// if key doesn't exist, an empty list is returned
// an error is returned when the value at key isn't a list
func (client *TestRedisClient) findList(key string) ([]string, error) {
//Lookup the store for the list
storedValue, found := client.store.Load(key)
Expand Down