mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 10:11:23 +02:00
Test Pause/Resume
This commit is contained in:
parent
8bb5770636
commit
a28451dc0c
@ -238,6 +238,52 @@ func TestFifoCancel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFifoPause(t *testing.T) {
|
||||
task1 := &Task{
|
||||
ID: "1",
|
||||
}
|
||||
|
||||
q := New().(*fifo)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
_, _ = q.Poll(noContext, func(*Task) bool { return true })
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
|
||||
q.Pause()
|
||||
t0 := time.Now()
|
||||
q.Push(noContext, task1)
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
q.Resume()
|
||||
|
||||
wg.Wait()
|
||||
t1 := time.Now()
|
||||
|
||||
if t1.Sub(t0) < 20 * time.Millisecond {
|
||||
t.Errorf("Should have waited til resume")
|
||||
}
|
||||
|
||||
q.Pause()
|
||||
q.Push(noContext, task1)
|
||||
q.Resume()
|
||||
_, _ = q.Poll(noContext, func(*Task) bool { return true })
|
||||
}
|
||||
|
||||
func TestFifoPauseResume(t *testing.T) {
|
||||
task1 := &Task{
|
||||
ID: "1",
|
||||
}
|
||||
|
||||
q := New().(*fifo)
|
||||
q.Pause()
|
||||
q.Push(noContext, task1)
|
||||
q.Resume()
|
||||
|
||||
_, _ = q.Poll(noContext, func(*Task) bool { return true })
|
||||
}
|
||||
|
||||
func TestShouldRun(t *testing.T) {
|
||||
task := &Task{
|
||||
ID: "2",
|
||||
|
Loading…
Reference in New Issue
Block a user