summaryrefslogtreecommitdiffstats
path: root/internal/pausedtimer
diff options
context:
space:
mode:
authorMarc Pervaz Boocha <marcpervaz@qburst.com>2025-02-25 09:46:37 +0530
committerMarc Pervaz Boocha <marcpervaz@qburst.com>2025-02-27 13:38:02 +0530
commit4e6d37095c6c75632ca9c4af2cbb3276364c2e5a (patch)
tree22540501437a80f8c36d3075eb8372444f513ad4 /internal/pausedtimer
parentAdded examples and documentation (diff)
downloadcache-4e6d37095c6c75632ca9c4af2cbb3276364c2e5a.tar
cache-4e6d37095c6c75632ca9c4af2cbb3276364c2e5a.tar.gz
cache-4e6d37095c6c75632ca9c4af2cbb3276364c2e5a.tar.bz2
cache-4e6d37095c6c75632ca9c4af2cbb3276364c2e5a.tar.lz
cache-4e6d37095c6c75632ca9c4af2cbb3276364c2e5a.tar.xz
cache-4e6d37095c6c75632ca9c4af2cbb3276364c2e5a.tar.zst
cache-4e6d37095c6c75632ca9c4af2cbb3276364c2e5a.zip
Add additional test cases to improve coverage and robustness
Diffstat (limited to '')
-rw-r--r--internal/pausedtimer/timer_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/pausedtimer/timer_test.go b/internal/pausedtimer/timer_test.go
index 6e15001..ac42690 100644
--- a/internal/pausedtimer/timer_test.go
+++ b/internal/pausedtimer/timer_test.go
@@ -12,6 +12,20 @@ func TestNew(t *testing.T) {
timer := New(d)
assert.Equal(t, d, timer.duration)
assert.NotNil(t, timer.Ticker)
+func TestPauseTimerPauseAndResume(t *testing.T) {
+ d := 1 * time.Second
+ timer := New(d)
+ timer.Stop() // Simulate pause
+ time.Sleep(500 * time.Millisecond)
+ timer.Resume()
+
+ select {
+ case <-timer.C:
+ // Timer should not have fired yet
+ t.Fatal("Timer fired too early")
+ case <-time.After(600 * time.Millisecond):
+ // Timer should fire after resuming
+ }
}
func TestPauseTimerReset(t *testing.T) {