MCPcopy
hub / github.com/kopia/kopia / TestTimerConcurrentStop

Function TestTimerConcurrentStop

internal/sleepable/sleepable_timer_test.go:121–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestTimerConcurrentStop(t *testing.T) {
122 // Set a small MaxSleepTime for testing
123 setMaxSleepTimeForTest(t, testMaxSleepTime)
124
125 t.Run("multiple stops", func(t *testing.T) {
126 start := clock.Now()
127 target := start.Add(100 * time.Millisecond)
128
129 timer := NewTimer(clock.Now, target)
130
131 var wg sync.WaitGroup
132 for range 10 {
133 wg.Go(timer.Stop)
134 }
135
136 wg.Wait()
137 time.Sleep(20 * time.Millisecond)
138
139 select {
140 case <-timer.C:
141 t.Error("timer triggered after being stopped")
142 default:
143 }
144 })
145}
146
147func TestTimerEdgeCases(t *testing.T) {
148 // Set a small MaxSleepTime for testing

Callers

nothing calls this directly

Calls 7

NowFunction · 0.92
setMaxSleepTimeForTestFunction · 0.85
NewTimerFunction · 0.85
RunMethod · 0.65
WaitMethod · 0.65
ErrorMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected