mirror of
https://github.com/alicebob/miniredis.git
synced 2024-07-21 14:03:53 +08:00
889458a92e
Removed duplicated code in tests using helper function. Signed-off-by: Wojciech Szarański <wojciech.szaranski@gmail.com>
46 lines
618 B
Go
46 lines
618 B
Go
package miniredis
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/alicebob/miniredis/v2/proto"
|
|
)
|
|
|
|
// Test OBJECT IDLETIME.
|
|
func TestObjectIdletime(t *testing.T) {
|
|
s, c := runWithClient(t)
|
|
|
|
{
|
|
start := time.Now()
|
|
s.SetTime(start)
|
|
|
|
mustOK(t, c,
|
|
"SET", "foo", "bar",
|
|
)
|
|
|
|
mustDo(t, c,
|
|
"OBJECT", "IDLETIME", "foo",
|
|
proto.Int(0),
|
|
)
|
|
|
|
s.SetTime(start.Add(time.Minute))
|
|
mustDo(t, c,
|
|
"OBJECT", "IDLETIME", "foo",
|
|
proto.Int(60),
|
|
)
|
|
|
|
s.Get("foo")
|
|
mustDo(t, c,
|
|
"object", "idletime", "foo",
|
|
proto.Int(0),
|
|
)
|
|
|
|
s.Del("foo")
|
|
mustDo(t, c,
|
|
"OBJECT", "IDLETIME", "foo",
|
|
proto.Nil,
|
|
)
|
|
}
|
|
}
|