This commit is contained in:
Fedor Korotkiy 2020-03-05 23:57:41 +03:00
parent d199667f5f
commit 4bd7608d85

View file

@ -121,6 +121,8 @@ func (w *errWriter) Write(p []byte) (n int, err error) {
} }
n = len(p) n = len(p)
w.n -= n
if w.n == 0 { if w.n == 0 {
err = iotest.ErrTimeout err = iotest.ErrTimeout
} }
@ -137,7 +139,7 @@ func TestWriterError(t *testing.T) {
n, err := w.Write(plaintext) n, err := w.Write(plaintext)
require.Equalf(t, plaintextBackup, plaintext, "Write must not modify the slice data, even temporarily.") require.Equalf(t, plaintextBackup, plaintext, "Write must not modify the slice data, even temporarily.")
require.NoError(t, err) require.Equal(t, err, iotest.ErrTimeout)
require.Equal(t, 512, n) require.Equal(t, 512, n)
require.Equal(t, out.buf.Bytes(), ciphertext[:512]) require.Equal(t, out.buf.Bytes(), ciphertext[:512])
} }