[#617] api/handler: Simplify tests

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-10-25 13:16:08 +03:00 committed by Alex Vanin
parent cb87fc693b
commit 18a6aca4b4
6 changed files with 166 additions and 237 deletions

View file

@ -155,7 +155,7 @@ func TestGetRange(t *testing.T) {
createTestBucket(tc, bktName)
content := "123456789abcdef"
putObjectContent(t, tc, bktName, objName, content)
putObjectContent(tc, bktName, objName, content)
full := getObjectRange(t, tc, bktName, objName, 0, len(content)-1)
require.Equal(t, content, string(full))
@ -170,11 +170,11 @@ func TestGetRange(t *testing.T) {
require.Equal(t, "bcdef", string(end))
}
func putObjectContent(t *testing.T, tc *handlerContext, bktName, objName, content string) {
func putObjectContent(hc *handlerContext, bktName, objName, content string) {
body := bytes.NewReader([]byte(content))
w, r := prepareTestPayloadRequest(tc, bktName, objName, body)
tc.Handler().PutObjectHandler(w, r)
assertStatus(t, w, http.StatusOK)
w, r := prepareTestPayloadRequest(hc, bktName, objName, body)
hc.Handler().PutObjectHandler(w, r)
assertStatus(hc.t, w, http.StatusOK)
}
func getObjectRange(t *testing.T, tc *handlerContext, bktName, objName string, start, end int) []byte {