From 4e6d37095c6c75632ca9c4af2cbb3276364c2e5a Mon Sep 17 00:00:00 2001 From: Marc Pervaz Boocha Date: Tue, 25 Feb 2025 09:46:37 +0530 Subject: Add additional test cases to improve coverage and robustness --- internal/pausedtimer/timer_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'internal/pausedtimer/timer_test.go') 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) { -- cgit v1.2.3-70-g09d2