From aebe6a77708877805e62136a89bef6e9c99e263e Mon Sep 17 00:00:00 2001 From: Sergey Novikov Date: Mon, 30 Jul 2018 02:52:26 +0200 Subject: [PATCH] Add cache tests --- cache_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cache_test.go b/cache_test.go index 71a4cba..452fc30 100644 --- a/cache_test.go +++ b/cache_test.go @@ -48,3 +48,20 @@ func TestDefaultCache_GetWithExpiration_Expired(t *testing.T) { t.Fatalf("val should be nil, got %v instead", val) } } + +func TestDefaultCache(t *testing.T) { + DefaultCache(time.Hour) + DefaultCache(0) + DefaultCache(-1) +} + +func TestDefaultCache_InvalidTtl(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Errorf("expected a panic") + } + }() + DefaultCache(-2) +} + +