Skip to content

Commit

Permalink
Add more test and fmt files.
Browse files Browse the repository at this point in the history
  • Loading branch information
chowchow316 committed Apr 14, 2017
1 parent 570d6ff commit b5189e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func (db *RedisDB) setUnion(keys []string) (setKey, error) {
}

// fastForward proceeds the current timestamp with duration, works as a time machine
func (db *RedisDB) fastForward(duration time.Duration) () {
func (db *RedisDB) fastForward(duration time.Duration) {
for _, key := range db.allKeys() {
value, ok := db.ttl[key]
if ok {
Expand Down
8 changes: 8 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ func Example() {
if _, err := s.DB(42).Get("foo"); err != miniredis.ErrKeyNotFound {
panic("Didn't use a different DB")
}

// Test key with expiration
s.SetTTL("foo", 60)
s.FastForward(60)
if _, err := s.Get("foo"); err == nil {
panic("Expect key expired, but still get value.")
}

// Or use a Check* function which Fail()s if the key is not what we expect
// (checks for existence, key type and the value)
// s.CheckGet(t, "foo", "bar")
Expand Down
2 changes: 1 addition & 1 deletion miniredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (m *Miniredis) TotalConnectionCount() int {
}

// FastForward proceeds the time of selected db by duration.
func (m *Miniredis) FastForward(duration time.Duration) () {
func (m *Miniredis) FastForward(duration time.Duration) {
for _, db := range m.dbs {
db.fastForward(duration)
}
Expand Down

0 comments on commit b5189e6

Please sign in to comment.