Skip to content

Commit 5a6efc0

Browse files
authored
Merge pull request #22 from jaavier/feature/get-counter
Function GetCounter
2 parents 563c262 + 793c63f commit 5a6efc0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

counters.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ func Decr(key string) int64 {
1212
return counter[key]
1313
}
1414

15+
func GetCounter(key string) int64 {
16+
return counter[key]
17+
}

tests/counters_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,13 @@ func TestCounters(t *testing.T) {
3030
t.Errorf("Error incrementing key %s", key)
3131
}
3232
})
33+
34+
t.Run("Get counter", func(t *testing.T) {
35+
var key = "counter"
36+
var expected int64 = 1
37+
sider.Incr(key)
38+
if sider.GetCounter(key) != expected {
39+
t.Errorf("Error getting counter %s", key)
40+
}
41+
})
3342
}

0 commit comments

Comments
 (0)