Skip to content

Commit

Permalink
Merge branch 'sheerun-shutdown'
Browse files Browse the repository at this point in the history
  • Loading branch information
djherbis committed Jan 13, 2018
2 parents 489cb4b + a70325a commit 311bd3b
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,25 +371,16 @@ func testShutdownAfterClose(t *testing.T, fs FileSystem) {

wg := sync.WaitGroup{}

wg.Add(2)
wg.Add(3)
er := errors.New("shutdown")

go func() {
time.Sleep(50 * time.Millisecond)
_, err := ioutil.ReadAll(r)
if err != nil {
t.Error("Shutdown should allow for any already created readers to finish reading")
}
r.Close()
f.Write([]byte("Hello"))
f.Close()
f.ShutdownWithErr(er)
wg.Done()
}()

f.Write([]byte("Hello"))
f.Close()

// This waits for any reads to finish, but prevents new reads as well
er := errors.New("shutdown")
f.ShutdownWithErr(er)

go func() {
time.Sleep(50 * time.Millisecond)
_, err := f.NextReader()
Expand All @@ -399,6 +390,16 @@ func testShutdownAfterClose(t *testing.T, fs FileSystem) {
wg.Done()
}()

go func() {
time.Sleep(50 * time.Millisecond)
defer r.Close()
_, err := ioutil.ReadAll(r)
if err != nil {
t.Error("Shutdown should allow for any already created readers to finish reading")
}
wg.Done()
}()

wg.Wait()

cleanup(f, t)
Expand Down

0 comments on commit 311bd3b

Please sign in to comment.