For https://github.com/docker/cli/pull/1014#issuecomment-409308139
(t *testing.T)
| 21 | |
| 22 | // For https://github.com/docker/cli/pull/1014#issuecomment-409308139 |
| 23 | func TestEOFWithError(t *testing.T) { |
| 24 | ctx := context.TODO() |
| 25 | c, err := New(ctx, "sh", "-c", "echo hello; echo some error >&2; exit 42") |
| 26 | assert.NilError(t, err) |
| 27 | b := make([]byte, 32) |
| 28 | n, err := c.Read(b) |
| 29 | assert.Check(t, is.Equal(len("hello\n"), n)) |
| 30 | assert.NilError(t, err) |
| 31 | n, err = c.Read(b) |
| 32 | assert.Check(t, is.Equal(0, n)) |
| 33 | assert.ErrorContains(t, err, "some error") |
| 34 | assert.ErrorContains(t, err, "42") |
| 35 | } |
| 36 | |
| 37 | func TestEOFWithoutError(t *testing.T) { |
| 38 | ctx := context.TODO() |