Skip to content

Commit

Permalink
Fix cancel test
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Mar 17, 2024
1 parent 116c176 commit 42547c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions worker2/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestExecSimple(t *testing.T) {
Expand Down Expand Up @@ -191,6 +190,8 @@ func TestExecCancel(t *testing.T) {
},
}

errCh := a.ErrorCh()

e := NewEngine()

ctx, cancel := context.WithCancel(context.Background())
Expand All @@ -200,10 +201,13 @@ func TestExecCancel(t *testing.T) {

e.Schedule(a)

time.Sleep(time.Second)
cancel()

e.Wait()

err := <-errCh

assert.ErrorIs(t, err, context.Canceled)
}

func TestExecDeps(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion worker2/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ func (e *Execution) Start(ctx context.Context) error {
e.suspendCh = make(chan struct{})

go func() {
e.errCh <- e.safeExec(ctx)
err := e.safeExec(ctx)
e.errCh <- err
}()
} else {
e.resumeAckCh <- struct{}{}
Expand Down

0 comments on commit 42547c8

Please sign in to comment.