+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
package main
import (
for i := 0; i < blocksize; i++ {
testdata[i] = byte(' ')
}
- copy(testdata[:3], []byte("foo"))
+ copy(testdata[1:4], []byte("foo"))
arv, err := arvadosclient.MakeArvadosClient()
c.Assert(err, check.Equals, nil)
arv.ApiToken = arvadostest.ActiveToken
c.Assert(err, check.Equals, nil)
loc, _, err := kc.PutB(testdata[:])
c.Assert(err, check.Equals, nil)
+ loc2, _, err := kc.PutB([]byte{'Z'})
+ c.Assert(err, check.Equals, nil)
- mtext := "."
- for i := 0; i < 4; i++ {
- mtext = mtext + " " + loc
- }
- mtext = mtext + fmt.Sprintf(" 0:%d:testdata.bin\n", blocksize*4)
+ mtext := fmt.Sprintf(". %s %s %s %s %s 1:%d:testdata.bin 0:1:space.txt\n", loc, loc, loc, loc, loc2, blocksize*4)
coll := map[string]interface{}{}
err = arv.Create("collections",
map[string]interface{}{
expectBody string
}{
{"0-2", true, "foo"},
+ {"-2", true, " Z"},
{"1-4", true, "oo "},
{"z-y", false, ""},
{"1000000-1000003", true, "foo "},
{"999999-1000003", true, " foo "},
{"2000000-2000003", true, "foo "},
{"1999999-2000002", true, " foo"},
- {"3999998-3999999", true, " "},
- {"3999998-4000004", true, " "},
- {"3999998-", true, " "},
+ {"3999998-3999999", true, " Z"},
+ {"3999998-4000004", true, " Z"},
+ {"3999998-", true, " Z"},
} {
- c.Logf("%+v", trial)
+ c.Logf("trial: %#v", trial)
resp := httptest.NewRecorder()
req := &http.Request{
Method: "GET",
if trial.expectObey {
c.Check(resp.Code, check.Equals, http.StatusPartialContent)
c.Check(resp.Body.Len(), check.Equals, len(trial.expectBody))
- c.Check(resp.Body.String()[:len(trial.expectBody)], check.Equals, trial.expectBody)
+ if resp.Body.Len() > 1000 {
+ c.Check(resp.Body.String()[:1000]+"[...]", check.Equals, trial.expectBody)
+ } else {
+ c.Check(resp.Body.String(), check.Equals, trial.expectBody)
+ }
} else {
- c.Check(resp.Code, check.Equals, http.StatusOK)
- c.Check(resp.Body.Len(), check.Equals, blocksize*4)
+ c.Check(resp.Code, check.Equals, http.StatusRequestedRangeNotSatisfiable)
}
}
}