Skip to content

Commit

Permalink
Merge pull request #22 from jaavier/feature/get-counter
Browse files Browse the repository at this point in the history
Function GetCounter
  • Loading branch information
jaavier committed Nov 14, 2022
2 parents 563c262 + 793c63f commit 5a6efc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions counters.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ func Decr(key string) int64 {
return counter[key]
}

func GetCounter(key string) int64 {
return counter[key]
}
9 changes: 9 additions & 0 deletions tests/counters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@ func TestCounters(t *testing.T) {
t.Errorf("Error incrementing key %s", key)
}
})

t.Run("Get counter", func(t *testing.T) {
var key = "counter"
var expected int64 = 1
sider.Incr(key)
if sider.GetCounter(key) != expected {
t.Errorf("Error getting counter %s", key)
}
})
}

0 comments on commit 5a6efc0

Please sign in to comment.