X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/44c95f99098fa6c6acbfa82d4b6cbc6015eb6e39..b91b5feb69b0939c99e4d71728c345ca98f5cc92:/sdk/go/keepclient/hashcheck_test.go diff --git a/sdk/go/keepclient/hashcheck_test.go b/sdk/go/keepclient/hashcheck_test.go index db748ee98e..44345afda6 100644 --- a/sdk/go/keepclient/hashcheck_test.go +++ b/sdk/go/keepclient/hashcheck_test.go @@ -8,9 +8,10 @@ import ( "bytes" "crypto/md5" "fmt" - . "gopkg.in/check.v1" "io" "io/ioutil" + + . "gopkg.in/check.v1" ) type HashcheckSuiteSuite struct{} @@ -86,4 +87,17 @@ func (h *HashcheckSuiteSuite) TestWriteTo(c *C) { c.Check(err, Equals, BadChecksum) <-done } + + // If WriteTo stops early due to a write error, return the + // write error (not "bad checksum"). + { + input := bytes.NewBuffer(make([]byte, 1<<26)) + hcr := HashCheckingReader{input, md5.New(), hash} + r, w := io.Pipe() + r.Close() + n, err := hcr.WriteTo(w) + c.Check(n, Equals, int64(0)) + c.Check(err, NotNil) + c.Check(err, Not(Equals), BadChecksum) + } }