aboutsummaryrefslogtreecommitdiff
path: root/tests/object_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-04-30 14:14:56 +0200
committerStefan Majewsky <majewsky@gmx.net>2018-05-02 19:33:46 +0200
commitf9749638e3393f471d7e28362795689bf37cc023 (patch)
tree57d56e88387b6ceef39ba23e29d009d683e44be4 /tests/object_test.go
parenta5ad3ae67e9c42aa738adae7e7fd535109bc9005 (diff)
downloadgo-schwift-f9749638e3393f471d7e28362795689bf37cc023.tar.gz
revamp the LargeObject API
I thought about this some more, and I believe the Writer-based approach in the previous version of the LargeObject API does not scale: It makes it very hard to write code that uploads segments without resorting to a buffer the same size as the segments. I don't want gigabyte-scale buffers filling up my RAM, so this commit switches to a different API based on Readers. LargeObject.Append() now behaves very similar to Object.Upload(), which I find quite nice.
Diffstat (limited to 'tests/object_test.go')
-rw-r--r--tests/object_test.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/object_test.go b/tests/object_test.go
index 6291527..251db9f 100644
--- a/tests/object_test.go
+++ b/tests/object_test.go
@@ -51,7 +51,7 @@ func TestObjectLifecycle(t *testing.T) {
err = o.Delete(nil, nil)
expectError(t, err, "expected 204 response, got 404 instead: <html><h1>Not Found</h1><p>The resource could not be found.</p></html>")
- err = o.Upload(bytes.NewReader([]byte("test")), nil)
+ err = o.Upload(bytes.NewReader([]byte("test")), nil, nil)
expectSuccess(t, err)
expectObjectExistence(t, o, true)
@@ -66,31 +66,31 @@ func TestObjectUpload(t *testing.T) {
//test upload with bytes.Reader
obj := c.Object("upload1")
- err := obj.Upload(bytes.NewReader(objectExampleContent), nil)
+ err := obj.Upload(bytes.NewReader(objectExampleContent), nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
//test upload with bytes.Buffer
obj = c.Object("upload2")
- err = obj.Upload(bytes.NewBuffer(objectExampleContent), nil)
+ err = obj.Upload(bytes.NewBuffer(objectExampleContent), nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
//test upload with strings.Reader
obj = c.Object("upload3")
- err = obj.Upload(strings.NewReader(string(objectExampleContent)), nil)
+ err = obj.Upload(strings.NewReader(string(objectExampleContent)), nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
//test upload with opaque io.Reader
obj = c.Object("upload4")
- err = obj.Upload(opaqueReader{bytes.NewReader(objectExampleContent)}, nil)
+ err = obj.Upload(opaqueReader{bytes.NewReader(objectExampleContent)}, nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
//test upload with io.Writer
obj = c.Object("upload5")
- err = obj.UploadWithWriter(nil, func(w io.Writer) error {
+ err = obj.UploadWithWriter(nil, nil, func(w io.Writer) error {
_, err := w.Write(objectExampleContent)
return err
})
@@ -99,13 +99,13 @@ func TestObjectUpload(t *testing.T) {
//test upload with empty reader (should create zero-byte-sized object)
obj = c.Object("upload6")
- err = obj.Upload(eofReader{}, nil)
+ err = obj.Upload(eofReader{}, nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, nil)
//test upload without reader (should create zero-byte-sized object)
obj = c.Object("upload7")
- err = obj.Upload(nil, nil)
+ err = obj.Upload(nil, nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, nil)
})
@@ -129,7 +129,7 @@ func TestObjectDownload(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
//upload example object
obj := c.Object("example")
- err := obj.Upload(bytes.NewReader(objectExampleContent), nil)
+ err := obj.Upload(bytes.NewReader(objectExampleContent), nil, nil)
expectSuccess(t, err)
//test download as string
@@ -170,7 +170,7 @@ func TestObjectUpdate(t *testing.T) {
expectError(t, err, "expected 202 response, got 404 instead: <html><h1>Not Found</h1><p>The resource could not be found.</p></html>")
//create object
- err = obj.Upload(nil, nil)
+ err = obj.Upload(nil, nil, nil)
expectSuccess(t, err)
hdr, err := obj.Headers()
@@ -190,7 +190,7 @@ func TestObjectUpdate(t *testing.T) {
func TestObjectCopyMove(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj1 := c.Object("location1")
- err := obj1.Upload(bytes.NewReader(objectExampleContent), nil)
+ err := obj1.Upload(bytes.NewReader(objectExampleContent), nil, nil)
expectSuccess(t, err)
expectObjectExistence(t, obj1, true)