aboutsummaryrefslogtreecommitdiffstats
path: root/internal/pausedtimer/timer_test.go
diff options
context:
space:
mode:
authorMarc Pervaz Boocha <marcpervaz@qburst.com>2025-04-08 16:15:27 +0530
committerMarc Pervaz Boocha <marcpervaz@qburst.com>2025-04-08 16:15:27 +0530
commitebb2dc540858155152b21549afd77e65118e1474 (patch)
tree74aa4929bb8dfd9a1823baa0b56cecadd99e91b4 /internal/pausedtimer/timer_test.go
parentAdded documentation and tests (diff)
downloadcache-ebb2dc540858155152b21549afd77e65118e1474.tar
cache-ebb2dc540858155152b21549afd77e65118e1474.tar.gz
cache-ebb2dc540858155152b21549afd77e65118e1474.tar.bz2
cache-ebb2dc540858155152b21549afd77e65118e1474.tar.lz
cache-ebb2dc540858155152b21549afd77e65118e1474.tar.xz
cache-ebb2dc540858155152b21549afd77e65118e1474.tar.zst
cache-ebb2dc540858155152b21549afd77e65118e1474.zip
Lint and bug fixes
Diffstat (limited to '')
-rw-r--r--internal/pausedtimer/timer_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/pausedtimer/timer_test.go b/internal/pausedtimer/timer_test.go
index 924c07c..5c54133 100644
--- a/internal/pausedtimer/timer_test.go
+++ b/internal/pausedtimer/timer_test.go
@@ -6,35 +6,47 @@ import (
)
func TestNew(t *testing.T) {
+ t.Parallel()
+
d := 1 * time.Second
timer := New(d)
+
if timer.duration != d {
t.Errorf("expected duration %#v, got %v", d, timer.duration)
}
+
if timer.Ticker == nil {
t.Error("expected Ticker to be non-nil")
}
}
func TestPauseTimerZeroDuration(t *testing.T) {
+ t.Parallel()
+
timer := New(0)
if timer.GetDuration() != 0 {
t.Errorf("expected duration %v, got %v", time.Duration(0), timer.GetDuration())
}
+
if timer.Ticker == nil {
t.Error("expected Ticker to be non-nil")
}
}
func TestPauseTimerResetToZero(t *testing.T) {
+ t.Parallel()
+
timer := New(1 * time.Second)
timer.Reset(0)
+
if timer.GetDuration() != 0 {
t.Errorf("expected duration %v, got %v", time.Duration(0), timer.GetDuration())
}
}
func TestPauseTimerPauseAndResume(t *testing.T) {
+ t.Parallel()
+
d := 1 * time.Second
timer := New(d)
timer.Stop() // Simulate pause
@@ -51,27 +63,36 @@ func TestPauseTimerPauseAndResume(t *testing.T) {
}
func TestPauseTimerReset(t *testing.T) {
+ t.Parallel()
+
d := 1 * time.Second
timer := New(d)
got := 2 * time.Second
timer.Reset(got)
+
if timer.duration != got {
t.Errorf("expected duration %v, got %v", got, timer.duration)
}
}
func TestPauseTimerResume(t *testing.T) {
+ t.Parallel()
+
d := 1 * time.Second
timer := NewStopped(d)
timer.Resume()
+
if timer.duration != d {
t.Errorf("expected duration %v, got %v", d, timer.duration)
}
}
func TestPauseTimerGetDuration(t *testing.T) {
+ t.Parallel()
+
d := 1 * time.Second
timer := New(d)
+
if timer.GetDuration() != d {
t.Errorf("expected duration %v, got %v", d, timer.GetDuration())
}