fix for non-deterministic test.
This commit is contained in:
parent
f88def71ec
commit
c55c4aa365
@ -51,7 +51,17 @@ func (rw *ChannelReadWriter) Write(p []byte) (n int, err error) {
|
||||
if rw.closed {
|
||||
return 0, errors.New("Write on closed channel")
|
||||
}
|
||||
|
||||
// if context is canceled it should never write
|
||||
select {
|
||||
case <-rw.ctx.Done():
|
||||
rw.Close()
|
||||
return 0, io.ErrClosedPipe
|
||||
default:
|
||||
}
|
||||
|
||||
select {
|
||||
// deal with closing duirng the write
|
||||
case <-rw.ctx.Done():
|
||||
rw.Close()
|
||||
return 0, io.ErrClosedPipe
|
||||
|
@ -11,7 +11,8 @@ type InmemoryConnection struct {
|
||||
|
||||
func NewInmemoryConnection(ctx context.Context, addr string) *InmemoryConnection {
|
||||
pipe := InmemoryConnection{
|
||||
ctx: ctx,
|
||||
ctx: ctx,
|
||||
// arbitrary unbuffered channel, unbuffered is more similar to TCP connections.
|
||||
frontToBack: make(chan []byte),
|
||||
backToFront: make(chan []byte),
|
||||
addr: addr,
|
||||
|
1
pkg/testsupport/inmemoryconnection_test.go
Normal file
1
pkg/testsupport/inmemoryconnection_test.go
Normal file
@ -0,0 +1 @@
|
||||
package testsupport
|
Loading…
Reference in New Issue
Block a user