Skip to content

Commit

Permalink
test: rkey - expire then set
Browse files Browse the repository at this point in the history
  • Loading branch information
nalgeon committed Jun 2, 2024
1 parent 4578305 commit 1bc2e54
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/rkey/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@ func TestExpire(t *testing.T) {
err := kkey.Expire("name", 10*time.Second)
testx.AssertEqual(t, err, core.ErrNotFound)
})
t.Run("expire then set", func(t *testing.T) {
db, kkey := getDB(t)
defer db.Close()

_ = db.Str().Set("name", "alice")

err := kkey.Expire("name", 0)
testx.AssertNoErr(t, err)

time.Sleep(1 * time.Millisecond)
_, err = kkey.Get("name")
testx.AssertEqual(t, err, core.ErrNotFound)

err = db.Str().Set("name", "bob")
testx.AssertNoErr(t, err)

key, _ := kkey.Get("name")
testx.AssertEqual(t, key.Version, 3)
testx.AssertEqual(t, key.ETime, (*int64)(nil))
})
}

func TestExpireAt(t *testing.T) {
Expand Down

0 comments on commit 1bc2e54

Please sign in to comment.