Skip to content

Commit

Permalink
Assertions added.
Browse files Browse the repository at this point in the history
Style fixed.
  • Loading branch information
alexeykiselev committed Dec 10, 2024
1 parent 00a9ebe commit 63a0305
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions pkg/execution/taskgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestCancelPropagation(t *testing.T) {
case errors.Is(e, errOther):
numOther++
default:
require.FailNow(t, "unexpected error: %v", e)
require.FailNowf(t, "No error is expected", "unexpected error: %v", e)
}
}

Expand Down Expand Up @@ -130,6 +130,8 @@ func TestWaitingForFinish(t *testing.T) {
}

func TestRegression(t *testing.T) {
defer goleak.VerifyNone(t)

t.Run("WaitRace", func(_ *testing.T) {
ready := make(chan struct{})
var g execution.TaskGroup
Expand All @@ -140,20 +142,26 @@ func TestRegression(t *testing.T) {

var wg sync.WaitGroup
wg.Add(2)
go func() { defer wg.Done(); _ = g.Wait() }()
go func() { defer wg.Done(); _ = g.Wait() }()
go func() {
defer wg.Done()
err := g.Wait()
require.NoError(t, err)
}()
go func() {
defer wg.Done()
err := g.Wait()
require.NoError(t, err)
}()

close(ready)
wg.Wait()
})
t.Run("WaitUnstarted", func(t *testing.T) {
defer func() {
if x := recover(); x != nil {
t.Errorf("Unexpected panic: %v", x)
}
}()
var g execution.TaskGroup
_ = g.Wait()
require.NotPanics(t, func() {
var g execution.TaskGroup
err := g.Wait()
require.NoError(t, err)
})
})
}

Expand Down

0 comments on commit 63a0305

Please sign in to comment.