Skip to content

Commit

Permalink
itest: enhance error messages in AssertSendEvents
Browse files Browse the repository at this point in the history
Improve error feedback to make diagnosing flaky tests easier.
  • Loading branch information
ffranr committed Jan 17, 2025
1 parent ffef906 commit 956b431
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,8 @@ func AssertSendEvents(t *testing.T, scriptKey []byte,
go func() {
select {
case <-timeout:
t.Logf("AssertSendEvents: cancelling stream after " +
"timeout")
stream.Cancel()

case <-success:
Expand All @@ -1020,8 +1022,15 @@ func AssertSendEvents(t *testing.T, scriptKey []byte,
require.NoError(t, err, "receiving send event")

require.True(t, sendsToKey(event))

// Check the event's error field for unexpected errors. Perform
// this check before verifying the expected send state, as
// errors might occur alongside an out-of-order send state.
require.Empty(
t, event.Error,
fmt.Sprintf("send event error: %x", event.Error),
)
require.Equal(t, startStatus.String(), event.SendState)
require.Empty(t, event.Error)

// Fully close the stream once we definitely no longer need the
// stream.
Expand Down

0 comments on commit 956b431

Please sign in to comment.