Files
docker-cli/cli/context/store/io_utils_test.go
Sebastiaan van Stijn 4fe6b837b7 bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 2c0e93063b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:43:18 +02:00

25 lines
475 B
Go

package store
import (
"io/ioutil"
"strings"
"testing"
"gotest.tools/v3/assert"
)
func TestLimitReaderReadAll(t *testing.T) {
r := strings.NewReader("Reader")
_, err := ioutil.ReadAll(r)
assert.NilError(t, err)
r = strings.NewReader("Test")
_, err = ioutil.ReadAll(&LimitedReader{R: r, N: 4})
assert.NilError(t, err)
r = strings.NewReader("Test")
_, err = ioutil.ReadAll(&LimitedReader{R: r, N: 2})
assert.Error(t, err, "read exceeds the defined limit")
}