aboutsummaryrefslogtreecommitdiffstats
path: root/utils_test.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--utils_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/utils_test.go b/utils_test.go
new file mode 100644
index 0000000..329b166
--- /dev/null
+++ b/utils_test.go
@@ -0,0 +1,36 @@
+package cache
+
+import (
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestNewPauseTimer(t *testing.T) {
+ d := 1 * time.Second
+ timer := newPauseTimer(d)
+ assert.Equal(t, d, timer.duration)
+ assert.NotNil(t, timer.Ticker)
+}
+
+func TestPauseTimerReset(t *testing.T) {
+ d := 1 * time.Second
+ timer := newPauseTimer(d)
+ newD := 2 * time.Second
+ timer.Reset(newD)
+ assert.Equal(t, newD, timer.duration)
+}
+
+func TestPauseTimerResume(t *testing.T) {
+ d := 1 * time.Second
+ timer := newPauseTimerStopped(d)
+ timer.Resume()
+ assert.Equal(t, d, timer.duration)
+}
+
+func TestPauseTimerGetDuration(t *testing.T) {
+ d := 1 * time.Second
+ timer := newPauseTimer(d)
+ assert.Equal(t, d, timer.GetDuration())
+}