Skip to content

Commit

Permalink
fix bug in waitForError function
Browse files Browse the repository at this point in the history
  • Loading branch information
kinluek committed Feb 7, 2020
1 parent 27f1e8b commit 6b49e86
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
3 changes: 0 additions & 3 deletions wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ func waitForError(ctx context.Context, errChan <-chan error) error {
return err
}
case <-ctx.Done():
if err := <-errChan; err != nil {
return err
}
return ctx.Err()
}
return nil
Expand Down
15 changes: 0 additions & 15 deletions wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@ func Test_waitForError(t *testing.T) {
t.Fatalf("expected waitForError() to return context.Canceled, got %v", err)
}
})

t.Run("error from error channel after context cancelled", func(t *testing.T) {
errChan := make(chan error)
ctx, cancel := context.WithCancel(context.Background())
ErrConfirmed := errors.New("confirmed")
go func() {
cancel()
time.Sleep(50 * time.Millisecond)
errChan <- ErrConfirmed
}()
if err := waitForError(ctx, errChan); err != ErrConfirmed {
t.Fatalf("expected waitForError() to return ErrConfirmed, got %v", err)
}
})

}

func Test_waitForInterval(t *testing.T) {
Expand Down

0 comments on commit 6b49e86

Please sign in to comment.