fix cipher-otc timeout test

This commit is contained in:
Michael 2023-03-19 16:16:58 +00:00 committed by Fedor Korotkiy
parent 366976e73a
commit b51400d119

View file

@ -54,6 +54,7 @@ func TestReader(t *testing.T) {
err error err error
result []byte result []byte
limit bool
}{ }{
{ {
name: "simple", name: "simple",
@ -83,8 +84,9 @@ func TestReader(t *testing.T) {
name: "timeout", name: "timeout",
r: iotest.TimeoutReader(bytes.NewBuffer(plaintext)), r: iotest.TimeoutReader(bytes.NewBuffer(plaintext)),
prng: bytes.NewBuffer(randomBytes), prng: bytes.NewBuffer(randomBytes),
result: ciphertext[:bytes.MinRead], result: ciphertext,
err: iotest.ErrTimeout, err: iotest.ErrTimeout,
limit: true,
}, },
} { } {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
@ -92,7 +94,11 @@ func TestReader(t *testing.T) {
buf, err := ioutil.ReadAll(r) buf, err := ioutil.ReadAll(r)
require.ErrorIs(t, err, testCase.err) require.ErrorIs(t, err, testCase.err)
if testCase.limit {
require.Equal(t, testCase.result[:len(buf)], buf)
} else {
require.Equal(t, testCase.result, buf) require.Equal(t, testCase.result, buf)
}
}) })
} }
} }