Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

Commit

Permalink
fix test to use recievers
Browse files Browse the repository at this point in the history
  • Loading branch information
thetinygoat committed May 22, 2020
1 parent c3dc896 commit 99b517c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions store_test.go
Expand Up @@ -6,27 +6,27 @@ import (
"time"
)

var testCacheObject = make(map[string]Cache)

func TestSet(t *testing.T) {
testCacheRef := GlobalCacheRef{}
testCacheRef.intializeGlobalCache()
var tests = []struct {
key, value string
ttl int

wantValue string
wantTTL time.Duration
}{
{"key1", "value1", 25, "value1", 25 * time.Second},
{"key1", "value1", -1, "value1", -1 * time.Second},
{"key2", "value2", 135, "value2", 135 * time.Second},
{"key3", "value3", 20, "value3", 20 * time.Second},
{"key1", "value12", 31, "value12", 31 * time.Second},
{"key1", "value13", 32, "value13", 32 * time.Second},
}
for _, tt := range tests {
testname := fmt.Sprintf("%s -> %s", tt.key, tt.value)
testname := fmt.Sprintf("%s->%s", tt.key, tt.value)
t.Run(testname, func(t *testing.T) {
testCacheObject = set(tt.key, tt.value, tt.ttl, testCacheObject)
ans := testCacheObject[tt.key]
testCacheRef.set(tt.key, tt.value, tt.ttl)
ans := testCacheRef.Cache[tt.key]
if ans.Data != tt.wantValue || ans.TTL != tt.wantTTL {
t.Errorf("error on key %s", tt.key)
}
Expand Down

0 comments on commit 99b517c

Please sign in to comment.