diff options
author | Marc Pervaz Boocha <marcpervaz@qburst.com> | 2025-02-20 17:58:55 +0530 |
---|---|---|
committer | Marc Pervaz Boocha <marcpervaz@qburst.com> | 2025-02-20 17:58:55 +0530 |
commit | 2f95efc236520485c7cc1439acae24140657d76c (patch) | |
tree | 10eac60e3eec8e6b3bb9c27e131cd531363c39d6 /utils_test.go | |
parent | Added Eviction and Options setup (diff) | |
download | cache-2f95efc236520485c7cc1439acae24140657d76c.tar cache-2f95efc236520485c7cc1439acae24140657d76c.tar.gz cache-2f95efc236520485c7cc1439acae24140657d76c.tar.bz2 cache-2f95efc236520485c7cc1439acae24140657d76c.tar.lz cache-2f95efc236520485c7cc1439acae24140657d76c.tar.xz cache-2f95efc236520485c7cc1439acae24140657d76c.tar.zst cache-2f95efc236520485c7cc1439acae24140657d76c.zip |
Add Tests and benchmarks
Diffstat (limited to '')
-rw-r--r-- | utils_test.go | 36 |
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()) +} |