projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '16427-undelete'
[arvados.git]
/
sdk
/
go
/
keepclient
/
collectionreader_test.go
diff --git
a/sdk/go/keepclient/collectionreader_test.go
b/sdk/go/keepclient/collectionreader_test.go
index 6e743f9a9e1a609c90dadbc86b22224ad8d77005..c6c9f044416a7fb93c4b898dfcafcdc121dfc1e4 100644
(file)
--- a/
sdk/go/keepclient/collectionreader_test.go
+++ b/
sdk/go/keepclient/collectionreader_test.go
@@
-1,3
+1,7
@@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
package keepclient
import (
package keepclient
import (
@@
-11,8
+15,8
@@
import (
"strconv"
"strings"
"strconv"
"strings"
- "git.
curoverse.com
/arvados.git/sdk/go/arvadosclient"
- "git.
curoverse.com
/arvados.git/sdk/go/arvadostest"
+ "git.
arvados.org
/arvados.git/sdk/go/arvadosclient"
+ "git.
arvados.org
/arvados.git/sdk/go/arvadostest"
check "gopkg.in/check.v1"
)
check "gopkg.in/check.v1"
)
@@
-78,6
+82,7
@@
func (h SuccessHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
if !ok {
resp.WriteHeader(http.StatusNotFound)
} else {
if !ok {
resp.WriteHeader(http.StatusNotFound)
} else {
+ resp.Header().Set("Content-Length", fmt.Sprintf("%d", len(buf)))
resp.Write(buf)
}
default:
resp.Write(buf)
}
default:
@@
-146,6
+151,7
@@
func (s *CollectionReaderUnit) TestCollectionReaderContent(c *check.C) {
c.Check(offset, check.Equals, int64(a))
buf := make([]byte, b-a)
n, err := io.ReadFull(rdr, buf)
c.Check(offset, check.Equals, int64(a))
buf := make([]byte, b-a)
n, err := io.ReadFull(rdr, buf)
+ c.Check(err, check.IsNil)
c.Check(n, check.Equals, b-a)
c.Check(string(buf), check.Equals, want[a:b])
}
c.Check(n, check.Equals, b-a)
c.Check(string(buf), check.Equals, want[a:b])
}
@@
-161,11
+167,11
@@
func (s *CollectionReaderUnit) TestCollectionReaderContent(c *check.C) {
func (s *CollectionReaderUnit) TestCollectionReaderManyBlocks(c *check.C) {
h := md5.New()
func (s *CollectionReaderUnit) TestCollectionReaderManyBlocks(c *check.C) {
h := md5.New()
- var testdata []byte
buf := make([]byte, 4096)
locs := make([]string, len(buf))
buf := make([]byte, 4096)
locs := make([]string, len(buf))
+ testdata := make([]byte, 0, len(buf)*len(buf))
filesize := 0
filesize := 0
- for i :=
0; i < len(locs); i++
{
+ for i :=
range locs
{
_, err := rand.Read(buf[:i])
h.Write(buf[:i])
locs[i], _, err = s.kc.PutB(buf[:i])
_, err := rand.Read(buf[:i])
h.Write(buf[:i])
locs[i], _, err = s.kc.PutB(buf[:i])
@@
-214,11
+220,12
@@
func (s *CollectionReaderUnit) TestCollectionReaderManyBlocks(c *check.C) {
c.Check(md5.Sum(buf), check.DeepEquals, md5.Sum(testdata))
c.Check(buf[:1000], check.DeepEquals, testdata[:1000])
c.Check(md5.Sum(buf), check.DeepEquals, md5.Sum(testdata))
c.Check(buf[:1000], check.DeepEquals, testdata[:1000])
+ expectPos := curPos + size + 12345
curPos, err = rdr.Seek(size+12345, io.SeekCurrent)
c.Check(err, check.IsNil)
curPos, err = rdr.Seek(size+12345, io.SeekCurrent)
c.Check(err, check.IsNil)
- c.Check(curPos, check.Equals,
size
)
+ c.Check(curPos, check.Equals,
expectPos
)
- curPos, err = rdr.Seek(8-
size
, io.SeekCurrent)
+ curPos, err = rdr.Seek(8-
curPos
, io.SeekCurrent)
c.Check(err, check.IsNil)
c.Check(curPos, check.Equals, int64(8))
c.Check(err, check.IsNil)
c.Check(curPos, check.Equals, int64(8))