aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2024-07-01 13:15:00 +0200
committerStefan Majewsky <majewsky@gmx.net>2024-07-01 13:17:16 +0200
commit3c489c0e29486ce1a5900c4ff87f403ebbbb70fa (patch)
treed2db245860b4ae0d5c319aaba4f3aa3cb126808c /tests
parent0fe0d65e49adf10a6a92a0412a2ec32e3d036b84 (diff)
downloadgo-schwift-3c489c0e29486ce1a5900c4ff87f403ebbbb70fa.tar.gz
fix autofixable lints
Diffstat (limited to 'tests')
-rw-r--r--tests/account_test.go14
-rw-r--r--tests/bulk_delete_test.go6
-rw-r--r--tests/bulk_upload_test.go14
-rw-r--r--tests/container_iterator_test.go20
-rw-r--r--tests/container_test.go4
-rw-r--r--tests/headers_test.go2
-rw-r--r--tests/largeobject_test.go58
-rw-r--r--tests/object_iterator_test.go32
-rw-r--r--tests/object_test.go46
-rw-r--r--tests/pkg.go2
-rw-r--r--tests/shared_test.go6
11 files changed, 102 insertions, 102 deletions
diff --git a/tests/account_test.go b/tests/account_test.go
index e4572ea..dc108ad 100644
--- a/tests/account_test.go
+++ b/tests/account_test.go
@@ -30,10 +30,10 @@ func TestAccountBasic(t *testing.T) {
if !expectSuccess(t, err) {
t.FailNow()
}
- //There are not a lot of things we can test here (besides testing that
- //Headers() does not fail, i.e. everything parses correctly), but
- //Content-Type is going to be either application/json or text/plain because
- //GET on an account lists the container names as plain text or JSON.
+ // There are not a lot of things we can test here (besides testing that
+ // Headers() does not fail, i.e. everything parses correctly), but
+ // Content-Type is going to be either application/json or text/plain because
+ // GET on an account lists the container names as plain text or JSON.
if hdr.Get("Content-Type") != "application/json; charset=utf-8" {
expectString(t, hdr.Get("Content-Type"), "text/plain; charset=utf-8")
}
@@ -42,7 +42,7 @@ func TestAccountBasic(t *testing.T) {
func TestAccountMetadata(t *testing.T) {
testWithAccount(t, func(a *schwift.Account) {
- //test creating some metadata
+ // test creating some metadata
hdr := schwift.NewAccountHeaders()
hdr.Metadata().Set("schwift-test1", "first")
hdr.Metadata().Set("schwift-test2", "second")
@@ -58,7 +58,7 @@ func TestAccountMetadata(t *testing.T) {
expectString(t, hdr.Metadata().Get("schwift-test1"), "first")
expectString(t, hdr.Metadata().Get("schwift-test2"), "second")
- //test deleting some metadata
+ // test deleting some metadata
hdr = schwift.NewAccountHeaders()
hdr.Metadata().Clear("schwift-test1")
err = a.Update(hdr, nil)
@@ -73,7 +73,7 @@ func TestAccountMetadata(t *testing.T) {
expectString(t, hdr.Metadata().Get("schwift-test1"), "")
expectString(t, hdr.Metadata().Get("schwift-test2"), "second")
- //test updating some metadata
+ // test updating some metadata
hdr = schwift.NewAccountHeaders()
hdr.Metadata().Set("schwift-test1", "will not be set")
hdr.Metadata().Del("schwift-test1")
diff --git a/tests/bulk_delete_test.go b/tests/bulk_delete_test.go
index 472feb8..0643a7c 100644
--- a/tests/bulk_delete_test.go
+++ b/tests/bulk_delete_test.go
@@ -68,9 +68,9 @@ func TestBulkDeleteError(t *testing.T) {
objs = objs[1:]
cs := []*schwift.Container{c}
- //not deleting all objects should lead to 409 Conflict when deleting the Container
- //(NOTE: actual Swift returns 400 here although I don't understand why
- //even after reading its code)
+ // not deleting all objects should lead to 409 Conflict when deleting the Container
+ // (NOTE: actual Swift returns 400 here although I don't understand why
+ // even after reading its code)
numDeleted, numNotFound, err := c.Account().BulkDelete(objs, cs, nil)
expectInt(t, numDeleted, len(objs))
expectInt(t, numNotFound, 0)
diff --git a/tests/bulk_upload_test.go b/tests/bulk_upload_test.go
index 0bdcb4e..cb64168 100644
--- a/tests/bulk_upload_test.go
+++ b/tests/bulk_upload_test.go
@@ -38,7 +38,7 @@ func TestBulkUploadSuccess(t *testing.T) {
obj2.FullName(): []byte("world"),
})
n, err := c.Account().BulkUpload(
- "", //upload path
+ "", // upload path
schwift.BulkUploadTar,
bytes.NewReader(archive),
nil,
@@ -56,7 +56,7 @@ func TestBulkUploadSuccess(t *testing.T) {
func TestBulkUploadArchiveError(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
n, err := c.Account().BulkUpload(
- c.Name(), //upload path
+ c.Name(), // upload path
schwift.BulkUploadTar,
strings.NewReader("This is not the TAR archive you're looking for."),
nil,
@@ -81,7 +81,7 @@ func TestBulkUploadObjectError(t *testing.T) {
obj2.Name(): []byte("world"),
})
n, err := c.Account().BulkUpload(
- c.Name(), //upload path
+ c.Name(), // upload path
schwift.BulkUploadTar,
bytes.NewReader(archive),
nil,
@@ -92,10 +92,10 @@ func TestBulkUploadObjectError(t *testing.T) {
expectInt(t, len(bulkErr.ObjectErrors), 1)
expectString(t, bulkErr.ObjectErrors[0].ContainerName, c.Name())
expectInt(t, bulkErr.ObjectErrors[0].StatusCode, 400)
- //^ We cannot match the ObjectName (or use expectError, for that matter)
- //here because Swift truncates the object name to its max length.
+ // ^ We cannot match the ObjectName (or use expectError, for that matter)
+ // here because Swift truncates the object name to its max length.
- //even if some files cannot be processed, the other files shall be stored correctly
+ // even if some files cannot be processed, the other files shall be stored correctly
expectObjectExistence(t, obj2, true)
expectObjectContent(t, obj2, []byte("world"))
})
@@ -127,7 +127,7 @@ func buildTarArchive(files map[string][]byte) []byte {
}
func buildInvalidObjectName() string {
- //5000 is more than the usual max_object_name_length of 1024
+ // 5000 is more than the usual max_object_name_length of 1024
buf := make([]byte, 5000)
for idx := range buf {
buf[idx] = 'a'
diff --git a/tests/container_iterator_test.go b/tests/container_iterator_test.go
index d682a59..cb482c1 100644
--- a/tests/container_iterator_test.go
+++ b/tests/container_iterator_test.go
@@ -31,13 +31,13 @@ func TestContainerIterator(t *testing.T) {
return fmt.Sprintf("schwift-test-listing%d", idx)
}
- //create test containers that can be listed
+ // create test containers that can be listed
for idx := 1; idx <= 4; idx++ {
_, err := a.Container(cname(idx)).EnsureExists()
expectSuccess(t, err)
}
- //test iteration with empty last page
+ // test iteration with empty last page
iter := a.Containers()
iter.Prefix = "schwift-test-listing"
cs, err := iter.NextPage(2)
@@ -53,7 +53,7 @@ func TestContainerIterator(t *testing.T) {
expectSuccess(t, err)
expectContainerNames(t, cs)
- //test iteration with partial last page
+ // test iteration with partial last page
iter = a.Containers()
iter.Prefix = "schwift-test-listing"
cs, err = iter.NextPage(3)
@@ -66,7 +66,7 @@ func TestContainerIterator(t *testing.T) {
expectSuccess(t, err)
expectContainerNames(t, cs)
- //test detailed iteration
+ // test detailed iteration
iter = a.Containers()
iter.Prefix = "schwift-test-listing"
cis, err := iter.NextPageDetailed(2)
@@ -82,7 +82,7 @@ func TestContainerIterator(t *testing.T) {
expectSuccess(t, err)
expectContainerInfos(t, cis)
- //test Foreach
+ // test Foreach
a.Invalidate()
iter = a.Containers()
iter.Prefix = "schwift-test-listing"
@@ -95,7 +95,7 @@ func TestContainerIterator(t *testing.T) {
expectInt(t, idx, 4)
expectAccountHeadersCached(t, a)
- //test ForeachDetailed
+ // test ForeachDetailed
a.Invalidate()
iter = a.Containers()
iter.Prefix = "schwift-test-listing"
@@ -108,21 +108,21 @@ func TestContainerIterator(t *testing.T) {
expectInt(t, idx, 4)
expectAccountHeadersCached(t, a)
- //test Collect
+ // test Collect
iter = a.Containers()
iter.Prefix = "schwift-test-listing"
cs, err = iter.Collect()
expectSuccess(t, err)
expectContainerNames(t, cs, cname(1), cname(2), cname(3), cname(4))
- //test CollectDetailed
+ // test CollectDetailed
iter = a.Containers()
iter.Prefix = "schwift-test-listing"
cis, err = iter.CollectDetailed()
expectSuccess(t, err)
expectContainerInfos(t, cis, cname(1), cname(2), cname(3), cname(4))
- //cleanup
+ // cleanup
iter = a.Containers()
iter.Prefix = "schwift-test-listing"
expectSuccess(t, iter.Foreach(func(c *schwift.Container) error {
@@ -171,7 +171,7 @@ func expectContainerInfos(t *testing.T, actualInfos []schwift.ContainerInfo, exp
idx, expectedNames[idx], info.Container.Name())
}
//TODO: upload test object of defined size to the listed containers to
- //check if this zero is not just the default value
+ // check if this zero is not just the default value
if info.BytesUsed != 0 {
t.Errorf("expected containers[%d] bytesUsed == 0, got %d",
idx, info.BytesUsed)
diff --git a/tests/container_test.go b/tests/container_test.go
index 26dcaac..da05506 100644
--- a/tests/container_test.go
+++ b/tests/container_test.go
@@ -45,8 +45,8 @@ func TestContainerLifecycle(t *testing.T) {
expectBool(t, schwift.Is(err, http.StatusNotFound), true)
expectBool(t, schwift.Is(err, http.StatusNoContent), false)
- //DELETE should be idempotent and not return success on non-existence, but
- //OpenStack LOVES to be inconsistent with everything (including, notably, itself)
+ // DELETE should be idempotent and not return success on non-existence, but
+ // OpenStack LOVES to be inconsistent with everything (including, notably, itself)
err = c.Delete(nil)
expectError(t, err, fmt.Sprintf("could not DELETE %q in Swift: expected 204 response, got 404 instead: <html><h1>Not Found</h1><p>The resource could not be found.</p></html>", containerName))
diff --git a/tests/headers_test.go b/tests/headers_test.go
index 6b229ae..2291c46 100644
--- a/tests/headers_test.go
+++ b/tests/headers_test.go
@@ -46,4 +46,4 @@ func TestParseAccountHeadersSuccess(t *testing.T) {
expectString(t, headers.Metadata().Get("FOO"), "bar")
}
-//TODO TestParseAccountHeadersError
+// TODO TestParseAccountHeadersError
diff --git a/tests/largeobject_test.go b/tests/largeobject_test.go
index ed61033..61812d8 100644
--- a/tests/largeobject_test.go
+++ b/tests/largeobject_test.go
@@ -45,7 +45,7 @@ func TestLargeObjectsBasic(t *testing.T) {
segment3 := getRandomSegmentContent(128)
segment4 := getRandomSegmentContent(128)
- //basic write example
+ // basic write example
lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: strategyStr + "-segments/",
@@ -69,7 +69,7 @@ func TestLargeObjectsBasic(t *testing.T) {
},
})
- //basic append example
+ // basic append example
lo, err = obj.AsLargeObject()
expectSuccess(t, err)
expectLargeObjectSetup(t, lo, strategy,
@@ -101,7 +101,7 @@ func TestLargeObjectsBasic(t *testing.T) {
},
})
- //basic truncate example
+ // basic truncate example
lo, err = obj.AsLargeObject()
expectSuccess(t, err)
err = lo.Truncate(&schwift.TruncateOptions{
@@ -111,7 +111,7 @@ func TestLargeObjectsBasic(t *testing.T) {
expectLargeObjectSetup(t, lo, strategy,
fmt.Sprintf("%s/%s-segments/", c.Name(), strategyStr))
- //verify that segments were deleted
+ // verify that segments were deleted
iter := c.Objects()
iter.Prefix = lo.SegmentPrefix()
names, err := iter.Collect()
@@ -158,13 +158,13 @@ func TestLargeObjectExpiration(t *testing.T) {
expectSuccess(t, lo.Append(bytes.NewReader([]byte(segment)), 128, headers.ToOpts()))
expectSuccess(t, lo.WriteManifest(headers.ToOpts()))
- //check object expiration
+ // check object expiration
hdr, err := obj.Headers()
expectSuccess(t, err)
objectExpiration := hdr.ExpiresAt().Get().Format("2006-01-02 15:04:05 +00:00 MST")
expectString(t, objectExpiration, expirationTime.Format("2006-01-02 15:04:05 +00:00 MST"))
- //check segment expiration
+ // check segment expiration
hdr, err = c.Object(strategyStr + "-segments/0000000000000001").Headers()
expectSuccess(t, err)
objectExpiration = hdr.ExpiresAt().Get().Format("2006-01-02 15:04:05 +00:00 MST")
@@ -178,7 +178,7 @@ func TestTruncateDuringOverwrite(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj := c.Object("largeobject")
- //setup phase: create a large object
+ // setup phase: create a large object
lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: "segments/",
@@ -195,7 +195,7 @@ func TestTruncateDuringOverwrite(t *testing.T) {
expectObjectExistence(t, c.Object("segments/0000000000000001"), true)
expectObjectExistence(t, c.Object("segments/0000000000000002"), true)
- //test phase: truncate using AsNewLargeObject
+ // test phase: truncate using AsNewLargeObject
lo, err = obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
Strategy: strategy,
@@ -256,8 +256,8 @@ func TestSLOWithDataSegment(t *testing.T) {
},
})
- //check that truncating this does not try to delete the nil segment.Object
- //in the data segment
+ // check that truncating this does not try to delete the nil segment.Object
+ // in the data segment
expectSuccess(t, lo.Truncate(&schwift.TruncateOptions{
DeleteSegments: true,
}))
@@ -278,7 +278,7 @@ func TestSLOWithRangeSegments(t *testing.T) {
}, nil)
expectSuccess(t, err)
- //the large object is composed out of three ranges such that the "X" are precisely cut out of segmentStr
+ // the large object is composed out of three ranges such that the "X" are precisely cut out of segmentStr
expectSuccess(t, lo.AddSegment(schwift.SegmentInfo{
Object: segmentObj,
RangeLength: 5,
@@ -327,7 +327,7 @@ func TestSLOGuessSegmentPrefix(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj := c.Object("largeobject")
- //setup phase: create an SLO
+ // setup phase: create an SLO
lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: "foo/bar/baz/",
@@ -340,7 +340,7 @@ func TestSLOGuessSegmentPrefix(t *testing.T) {
expectSuccess(t, lo.Append(bytes.NewReader([]byte(segment2)), 0, nil))
expectSuccess(t, lo.WriteManifest(nil))
- //now create a fresh SLO and check if it infers the correct SegmentPrefix
+ // now create a fresh SLO and check if it infers the correct SegmentPrefix
lo, err = obj.AsLargeObject()
expectSuccess(t, err)
expectString(t, lo.SegmentContainer().Name(), c.Name())
@@ -353,7 +353,7 @@ func TestDeleteLargeObjectAndKeepSegments(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj := c.Object("largeobject")
- //setup phase: create a large object
+ // setup phase: create a large object
lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: "foo/bar/baz/",
@@ -367,7 +367,7 @@ func TestDeleteLargeObjectAndKeepSegments(t *testing.T) {
expectSuccess(t, lo.Append(bytes.NewReader([]byte(segment2)), 0, nil))
expectSuccess(t, lo.WriteManifest(nil))
- //test deletion that keeps segments
+ // test deletion that keeps segments
expectSuccess(t, obj.Delete(nil, nil))
iter := c.Objects()
@@ -386,7 +386,7 @@ func TestDeleteLargeObjectIncludingSegments(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj := c.Object("largeobject")
- //setup phase: create a large object
+ // setup phase: create a large object
lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: "foo/bar/baz/",
@@ -400,7 +400,7 @@ func TestDeleteLargeObjectIncludingSegments(t *testing.T) {
expectSuccess(t, lo.Append(bytes.NewReader([]byte(segment2)), 0, nil))
expectSuccess(t, lo.WriteManifest(nil))
- //test deletion that keeps segments
+ // test deletion that keeps segments
expectSuccess(t, obj.Delete(&schwift.DeleteOptions{DeleteSegments: true}, nil))
iter := c.Objects()
@@ -417,7 +417,7 @@ func TestOverwriteLargeObjectAndKeepSegments(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj := c.Object("largeobject")
- //setup phase: create a large object
+ // setup phase: create a large object
lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: "foo/bar/baz/",
@@ -431,7 +431,7 @@ func TestOverwriteLargeObjectAndKeepSegments(t *testing.T) {
expectSuccess(t, lo.Append(bytes.NewReader([]byte(segment2)), 0, nil))
expectSuccess(t, lo.WriteManifest(nil))
- //test overwriting that keeps segments
+ // test overwriting that keeps segments
expectSuccess(t, obj.Upload(bytes.NewReader(objectExampleContent), nil, nil))
iter := c.Objects()
@@ -450,7 +450,7 @@ func TestOverwriteLargeObjectIncludingSegments(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj := c.Object("largeobject")
- //setup phase: create a large object
+ // setup phase: create a large object
lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: "foo/bar/baz/",
@@ -464,7 +464,7 @@ func TestOverwriteLargeObjectIncludingSegments(t *testing.T) {
expectSuccess(t, lo.Append(bytes.NewReader([]byte(segment2)), 0, nil))
expectSuccess(t, lo.WriteManifest(nil))
- //test overwriting that deletes segments
+ // test overwriting that deletes segments
expectSuccess(t, obj.Upload(
bytes.NewReader(objectExampleContent),
&schwift.UploadOptions{DeleteSegments: true},
@@ -477,14 +477,14 @@ func TestOverwriteLargeObjectIncludingSegments(t *testing.T) {
expectSuccess(t, err)
expectObjectNames(t, names)
- //test overwriting that wants to delete segments, but there aren't any
+ // test overwriting that wants to delete segments, but there aren't any
expectSuccess(t, obj.Upload(
bytes.NewReader(objectExampleContent),
&schwift.UploadOptions{DeleteSegments: true},
nil,
))
- //while we're at it, test the same for deletion
+ // while we're at it, test the same for deletion
expectSuccess(t, obj.Delete(
&schwift.DeleteOptions{DeleteSegments: true},
nil,
@@ -503,13 +503,13 @@ func TestAddInvalidSegments(t *testing.T) {
}, nil)
expectSuccess(t, err)
- //must have either backing object or data
+ // must have either backing object or data
expectError(t, lo.AddSegment(schwift.SegmentInfo{
Object: nil,
Data: nil,
}), schwift.ErrSegmentInvalid.Error())
- //if data segment, must not have any other attribute
+ // if data segment, must not have any other attribute
expectError(t, lo.AddSegment(schwift.SegmentInfo{
Data: []byte("foo"),
Object: obj,
@@ -531,14 +531,14 @@ func TestAddInvalidSegments(t *testing.T) {
RangeLength: 1,
}), schwift.ErrSegmentInvalid.Error())
- //malformed range
+ // malformed range
expectError(t, lo.AddSegment(schwift.SegmentInfo{
Object: obj,
RangeOffset: -1,
RangeLength: 0,
}), schwift.ErrSegmentInvalid.Error())
- //DLO is strict about the SegmentContainer and SegmentPrefix, but SLO accepts it
+ // DLO is strict about the SegmentContainer and SegmentPrefix, but SLO accepts it
c2 := c.Account().Container("foo")
err = lo.AddSegment(schwift.SegmentInfo{
Object: c2.Object("foo"),
@@ -583,13 +583,13 @@ func expectLargeObject(t *testing.T, obj *schwift.Object, expected []schwift.Seg
for idx, as := range actual {
es := expected[idx]
if len(es.Data) > 0 {
- //expecting data segment
+ // expecting data segment
if string(es.Data) != string(as.Data) {
t.Errorf("expected segments[%d].Data == %q, got %q",
idx, string(es.Data), string(as.Data))
}
} else {
- //expecting segment backed by object
+ // expecting segment backed by object
if as.Object.FullName() != es.Object.FullName() {
t.Errorf("expected segments[%d].Object.FullName() == %q, got %q",
idx, es.Object.FullName(), as.Object.FullName())
diff --git a/tests/object_iterator_test.go b/tests/object_iterator_test.go
index a1334d1..2f9143d 100644
--- a/tests/object_iterator_test.go
+++ b/tests/object_iterator_test.go
@@ -36,7 +36,7 @@ func TestObjectIterator(t *testing.T) {
return fmt.Sprintf("schwift-test-listing%d", idx)
}
- //create test objects that can be listed
+ // create test objects that can be listed
for idx := 1; idx <= 4; idx++ {
hdr := schwift.NewObjectHeaders()
hdr.ContentType().Set("application/json")
@@ -44,7 +44,7 @@ func TestObjectIterator(t *testing.T) {
expectSuccess(t, err)
}
- //test iteration with empty last page
+ // test iteration with empty last page
iter := c.Objects()
iter.Prefix = "schwift-test-listing"
os, err := iter.NextPage(2)
@@ -60,7 +60,7 @@ func TestObjectIterator(t *testing.T) {
expectSuccess(t, err)
expectObjectNames(t, os)
- //test iteration with partial last page
+ // test iteration with partial last page
iter = c.Objects()
iter.Prefix = "schwift-test-listing"
os, err = iter.NextPage(3)
@@ -73,7 +73,7 @@ func TestObjectIterator(t *testing.T) {
expectSuccess(t, err)
expectObjectNames(t, os)
- //test detailed iteration
+ // test detailed iteration
iter = c.Objects()
iter.Prefix = "schwift-test-listing"
ois, err := iter.NextPageDetailed(2)
@@ -89,7 +89,7 @@ func TestObjectIterator(t *testing.T) {
expectSuccess(t, err)
expectObjectInfos(t, ois)
- //test Foreach
+ // test Foreach
c.Invalidate()
iter = c.Objects()
iter.Prefix = "schwift-test-listing"
@@ -102,7 +102,7 @@ func TestObjectIterator(t *testing.T) {
expectInt(t, idx, 4)
expectContainerHeadersCached(t, c)
- //test ForeachDetailed
+ // test ForeachDetailed
c.Invalidate()
iter = c.Objects()
iter.Prefix = "schwift-test-listing"
@@ -115,14 +115,14 @@ func TestObjectIterator(t *testing.T) {
expectInt(t, idx, 4)
expectContainerHeadersCached(t, c)
- //test Collect
+ // test Collect
iter = c.Objects()
iter.Prefix = "schwift-test-listing"
os, err = iter.Collect()
expectSuccess(t, err)
expectObjectNames(t, os, oname(1), oname(2), oname(3), oname(4))
- //test CollectDetailed
+ // test CollectDetailed
iter = c.Objects()
iter.Prefix = "schwift-test-listing"
ois, err = iter.CollectDetailed()
@@ -133,7 +133,7 @@ func TestObjectIterator(t *testing.T) {
func TestPseudoDirectories(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
- //create test objects that can be listed
+ // create test objects that can be listed
objectNames := []string{
"foo/1",
"foo/2",
@@ -150,7 +150,7 @@ func TestPseudoDirectories(t *testing.T) {
expectSuccess(t, err)
}
- //test iteration with Delimiter and no Prefix
+ // test iteration with Delimiter and no Prefix
iter := c.Objects()
iter.Delimiter = "/"
os, err := iter.Collect()
@@ -163,7 +163,7 @@ func TestPseudoDirectories(t *testing.T) {
expectSuccess(t, err)
expectObjectInfos(t, ois, "subdir:foo/")
- //test iteration with Delimited and Prefix
+ // test iteration with Delimited and Prefix
iter = c.Objects()
iter.Prefix = "foo/"
iter.Delimiter = "/"
@@ -182,7 +182,7 @@ func TestPseudoDirectories(t *testing.T) {
func TestObjectIteratorWithSymlinks(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
- //create test objects that can be listed
+ // create test objects that can be listed
objectNames := []string{
"foo/1",
"foo/3",
@@ -194,7 +194,7 @@ func TestObjectIteratorWithSymlinks(t *testing.T) {
expectSuccess(t, err)
}
- //create a test symlink
+ // create a test symlink
expectSuccess(t, c.Object("foo/2").SymlinkTo(c.Object("foo/1"), nil, nil))
iter := c.Objects()
@@ -244,7 +244,7 @@ func expectObjectInfos(t *testing.T, actualInfos []schwift.ObjectInfo, expectedN
return
}
for idx, info := range actualInfos {
- //case 1: pseudo-directory
+ // case 1: pseudo-directory
if strings.HasPrefix(expectedNames[idx], "subdir:") {
expectedSubdir := strings.TrimPrefix(expectedNames[idx], "subdir:")
if expectedSubdir != info.SubDirectory {
@@ -262,7 +262,7 @@ func expectObjectInfos(t *testing.T, actualInfos []schwift.ObjectInfo, expectedN
idx, info.SubDirectory)
}
- //case 2: symlink
+ // case 2: symlink
if strings.HasPrefix(expectedNames[idx], "symlink:") {
fields := strings.SplitN(strings.TrimPrefix(expectedNames[idx], "symlink:"), ">", 2)
expectedName, expectedTargetName := fields[0], fields[1]
@@ -302,7 +302,7 @@ func expectObjectInfos(t *testing.T, actualInfos []schwift.ObjectInfo, expectedN
continue
}
- //case 3: regular object
+ // case 3: regular object
if info.Object == nil {
t.Errorf("expected objects[%d].Name() == %q, got object == nil",
idx, expectedNames[idx])
diff --git a/tests/object_test.go b/tests/object_test.go
index cfcc908..81925d6 100644
--- a/tests/object_test.go
+++ b/tests/object_test.go
@@ -46,8 +46,8 @@ func TestObjectLifecycle(t *testing.T) {
expectBool(t, schwift.Is(err, http.StatusNotFound), true)
expectBool(t, schwift.Is(err, http.StatusNoContent), false)
- //DELETE should be idempotent and not return success on non-existence, but
- //OpenStack LOVES to be inconsistent with everything (including, notably, itself)
+ // DELETE should be idempotent and not return success on non-existence, but
+ // OpenStack LOVES to be inconsistent with everything (including, notably, itself)
err = o.Delete(nil, nil)
expectError(t, err, fmt.Sprintf("could not DELETE %q in Swift: expected 204 response, got 404 instead: <html><h1>Not Found</h1><p>The resource could not be found.</p></html>", o.FullName()))
@@ -63,31 +63,31 @@ func TestObjectLifecycle(t *testing.T) {
func TestObjectUpload(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
- //test upload with bytes.Reader
+ // test upload with bytes.Reader
obj := c.Object("upload1")
err := obj.Upload(bytes.NewReader(objectExampleContent), nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
- //test upload with bytes.Buffer
+ // test upload with bytes.Buffer
obj = c.Object("upload2")
err = obj.Upload(bytes.NewBuffer(objectExampleContent), nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
- //test upload with strings.Reader
+ // test upload with strings.Reader
obj = c.Object("upload3")
err = obj.Upload(strings.NewReader(string(objectExampleContent)), nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
- //test upload with opaque io.Reader
+ // test upload with opaque io.Reader
obj = c.Object("upload4")
err = obj.Upload(opaqueReader{bytes.NewReader(objectExampleContent)}, nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
- //test upload with io.Writer
+ // test upload with io.Writer
obj = c.Object("upload5")
err = obj.UploadFromWriter(nil, nil, func(w io.Writer) error {
_, err := w.Write(objectExampleContent)
@@ -96,13 +96,13 @@ func TestObjectUpload(t *testing.T) {
expectSuccess(t, err)
expectObjectContent(t, obj, objectExampleContent)
- //test upload with empty reader (should create zero-byte-sized object)
+ // test upload with empty reader (should create zero-byte-sized object)
obj = c.Object("upload6")
err = obj.Upload(eofReader{}, nil, nil)
expectSuccess(t, err)
expectObjectContent(t, obj, nil)
- //test upload without reader (should create zero-byte-sized object)
+ // test upload without reader (should create zero-byte-sized object)
obj = c.Object("upload7")
err = obj.Upload(nil, nil, nil)
expectSuccess(t, err)
@@ -126,22 +126,22 @@ func (r opaqueReader) Read(buf []byte) (int, error) {
func TestObjectDownload(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
- //upload example object
+ // upload example object
obj := c.Object("example")
err := obj.Upload(bytes.NewReader(objectExampleContent), nil, nil)
expectSuccess(t, err)
- //test download as string
+ // test download as string
str, err := obj.Download(nil).AsString()
expectSuccess(t, err)
expectString(t, str, string(objectExampleContent))
- //test download as byte slice
+ // test download as byte slice
buf, err := obj.Download(nil).AsByteSlice()
expectSuccess(t, err)
expectString(t, string(buf), string(objectExampleContent))
- //test download as io.ReadCloser slice
+ // test download as io.ReadCloser slice
reader, err := obj.Download(nil).AsReadCloser()
expectSuccess(t, err)
buf = make([]byte, 4)
@@ -161,14 +161,14 @@ func TestObjectUpdate(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
obj := c.Object("example")
- //test that metadata update fails for non-existing object
+ // test that metadata update fails for non-existing object
newHeaders := schwift.NewObjectHeaders()
newHeaders.ContentType().Set("application/json")
err := obj.Update(newHeaders, nil)
expectBool(t, schwift.Is(err, http.StatusNotFound), true)
expectError(t, err, fmt.Sprintf("could not POST %q in Swift: expected 202 response, got 404 instead: <html><h1>Not Found</h1><p>The resource could not be found.</p></html>", obj.FullName()))
- //create object
+ // create object
err = obj.Upload(nil, nil, nil)
expectSuccess(t, err)
@@ -176,7 +176,7 @@ func TestObjectUpdate(t *testing.T) {
expectSuccess(t, err)
expectString(t, hdr.ContentType().Get(), "application/octet-stream")
- //now the metadata update should work
+ // now the metadata update should work
err = obj.Update(newHeaders, nil)
expectSuccess(t, err)
obj.Invalidate()
@@ -203,40 +203,40 @@ func TestObjectCopy(t *testing.T) {
func TestSymlinkOperations(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
- //create a test object that we can link to
+ // create a test object that we can link to
obj1 := c.Object("target")
err := obj1.Upload(bytes.NewReader(objectExampleContent), nil, nil)
expectSuccess(t, err)
expectObjectExistence(t, obj1, true)
- //create a symlink
+ // create a symlink
obj2 := c.Object("symlink")
expectSuccess(t, obj2.SymlinkTo(obj1, nil, nil))
expectObjectExistence(t, obj2, true)
expectObjectSymlink(t, obj2, obj1)
expectObjectContent(t, obj2, objectExampleContent)
- //overwrite symlink with normal object
+ // overwrite symlink with normal object
otherContent := []byte("abc")
expectSuccess(t, obj2.Upload(bytes.NewReader(otherContent), nil, nil))
expectObjectExistence(t, obj2, true)
expectObjectSymlink(t, obj2, nil)
expectObjectContent(t, obj2, otherContent)
- //overwrite normal object with symlink
+ // overwrite normal object with symlink
expectSuccess(t, obj2.SymlinkTo(obj1, nil, nil))
expectObjectExistence(t, obj2, true)
expectObjectSymlink(t, obj2, obj1)
expectObjectContent(t, obj2, objectExampleContent)
- //deep-copy symlink
+ // deep-copy symlink
obj3 := c.Object("copy")
expectSuccess(t, obj2.CopyTo(obj3, nil, nil))
expectObjectExistence(t, obj3, true)
expectObjectSymlink(t, obj3, nil)
expectObjectContent(t, obj3, objectExampleContent)
- //shallow-copy symlink
+ // shallow-copy symlink
expectSuccess(t, obj2.CopyTo(obj3, &schwift.CopyOptions{
ShallowCopySymlinks: true,
}, nil))
@@ -244,7 +244,7 @@ func TestSymlinkOperations(t *testing.T) {
expectObjectSymlink(t, obj3, obj1)
expectObjectContent(t, obj3, objectExampleContent)
- //delete symlink
+ // delete symlink
expectSuccess(t, obj2.Delete(nil, nil))
expectObjectExistence(t, obj2, false)
})
diff --git a/tests/pkg.go b/tests/pkg.go
index 571e0eb..7edd248 100644
--- a/tests/pkg.go
+++ b/tests/pkg.go
@@ -1,3 +1,3 @@
package tests
-//This empty source file is required to make `make test` work.
+// This empty source file is required to make `make test` work.
diff --git a/tests/shared_test.go b/tests/shared_test.go
index cd3b109..a3ef610 100644
--- a/tests/shared_test.go
+++ b/tests/shared_test.go
@@ -43,7 +43,7 @@ func testWithAccount(t *testing.T, testCode func(a *schwift.Account)) {
var client *gophercloud.ServiceClient
if stAuth == "" && stUser == "" && stKey == "" {
- //option 1: Keystone authentication
+ // option 1: Keystone authentication
provider, err := clientconfig.AuthenticatedClient(context.TODO(), nil)
if err != nil {
t.Errorf("clientconfig.AuthenticatedClient returned: " + err.Error())
@@ -56,7 +56,7 @@ func testWithAccount(t *testing.T, testCode func(a *schwift.Account)) {
return
}
} else {
- //option 2: Swift authentication v1
+ // option 2: Swift authentication v1
provider, err := openstack.NewClient(stAuth)
if err != nil {
t.Errorf("openstack.NewClient returned: " + err.Error())
@@ -92,7 +92,7 @@ func testWithContainer(t *testing.T, testCode func(c *schwift.Container)) {
testCode(container)
- //cleanup
+ // cleanup
exists, err := container.Exists()
expectSuccess(t, err)
if exists {