Files
opsxdb/server/internal/db/redis_ttl_test.go
T

30 lines
525 B
Go

package db
import (
"testing"
"time"
)
func TestTTLSecondsSentinels(t *testing.T) {
cases := []struct {
in time.Duration
want int64
}{
{time.Duration(-1), -1},
{-1 * time.Nanosecond, -1},
{-1 * time.Second, -1},
{time.Duration(-2), -2},
{-2 * time.Nanosecond, -2},
{-2 * time.Second, -2},
{0, 0},
{5 * time.Second, 5},
{1500 * time.Millisecond, 1},
}
for _, c := range cases {
got := ttlSeconds(c.in)
if got != c.want {
t.Fatalf("ttlSeconds(%v)=%d want %d", c.in, got, c.want)
}
}
}