Skip to content

Commit

Permalink
Modify the Channel test to catch docker#29
Browse files Browse the repository at this point in the history
Signed-off-by: Adrián Orive <aorive@ikerlan.es>
  • Loading branch information
IK-Adrian committed May 3, 2018
1 parent 9461782 commit cc42618
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func TestChannel(t *testing.T) {
const nevents = 100

sink := NewChannel(0)
sink := NewChannel(10)

go func() {
var wg sync.WaitGroup
Expand All @@ -25,13 +25,6 @@ func TestChannel(t *testing.T) {
}
wg.Wait()
sink.Close()

// now send another bunch of events and ensure we stay closed
for i := 1; i <= nevents; i++ {
if err := sink.Write(i); err != ErrSinkClosed {
t.Fatalf("unexpected error: %v != %v", err, ErrSinkClosed)
}
}
}()

var received int
Expand All @@ -54,4 +47,18 @@ loop:
if received != nevents {
t.Fatalf("events did not make it through sink: %v != %v", received, nevents)
}

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
// now send another bunch of events and ensure we stay closed
for i := 1; i <= nevents; i++ {
if err := sink.Write(i); err != ErrSinkClosed {
t.Fatalf("unexpected error #%v: %v != %v",
i, err, ErrSinkClosed)
}
}
}()
wg.Wait()
}

0 comments on commit cc42618

Please sign in to comment.