miniredis/cmd_object_test.go
Wojciech Szarański 889458a92e Move create of client in tests to helper function
Removed duplicated code in tests using helper function.

Signed-off-by: Wojciech Szarański <wojciech.szaranski@gmail.com>
2024-03-27 19:55:20 +01:00

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,
)
}
}