Skip to content

Commit

Permalink
Fix non-deterministic test
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael committed Jul 7, 2024
1 parent eeab7f4 commit 4b63f9a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions grpc/middleware/canceler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"context"
"testing"

grpcm "goa.design/goa/v3/grpc/middleware"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"

grpcm "goa.design/goa/v3/grpc/middleware"
)

type (
Expand Down Expand Up @@ -46,16 +48,9 @@ func TestStreamCanceler(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

go func() {
cancel()
}()

if err := grpcm.StreamCanceler(ctx)(nil, c.stream, stream, c.handler); err != nil {
if err.Error() != "server is stopping" {
t.Errorf("StreamCanceler error: %v", err)
}
}
interceptor := grpcm.StreamCanceler(ctx)
cancel()
assert.NoError(t, interceptor(nil, c.stream, stream, c.handler))
})
}
}

0 comments on commit 4b63f9a

Please sign in to comment.