aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/account_test.go1
-rw-r--r--tests/bulk_upload_test.go4
-rw-r--r--tests/container_test.go2
-rw-r--r--tests/field_test.go4
-rw-r--r--tests/largeobject_test.go8
-rw-r--r--tests/object_test.go4
-rw-r--r--tests/shared_test.go17
7 files changed, 14 insertions, 26 deletions
diff --git a/tests/account_test.go b/tests/account_test.go
index f5925f0..e4572ea 100644
--- a/tests/account_test.go
+++ b/tests/account_test.go
@@ -89,6 +89,5 @@ func TestAccountMetadata(t *testing.T) {
}
expectString(t, hdr.Metadata().Get("schwift-test1"), "")
expectString(t, hdr.Metadata().Get("schwift-test2"), "changed")
-
})
}
diff --git a/tests/bulk_upload_test.go b/tests/bulk_upload_test.go
index 6cbae42..d810cf5 100644
--- a/tests/bulk_upload_test.go
+++ b/tests/bulk_upload_test.go
@@ -62,7 +62,7 @@ func TestBulkUploadArchiveError(t *testing.T) {
)
expectInt(t, n, 0)
expectError(t, err, "400 Bad Request: Invalid Tar File: truncated header")
- bulkErr := err.(schwift.BulkError)
+ bulkErr := err.(schwift.BulkError) //nolint:errcheck
expectInt(t, bulkErr.StatusCode, 400)
expectString(t, bulkErr.OverallError, "Invalid Tar File: truncated header")
expectInt(t, len(bulkErr.ObjectErrors), 0)
@@ -87,7 +87,7 @@ func TestBulkUploadObjectError(t *testing.T) {
)
expectInt(t, n, 1)
expectError(t, err, "400 Bad Request (+1 object errors)")
- bulkErr := err.(schwift.BulkError)
+ bulkErr := err.(schwift.BulkError) //nolint:errcheck
expectInt(t, len(bulkErr.ObjectErrors), 1)
expectString(t, bulkErr.ObjectErrors[0].ContainerName, c.Name())
expectInt(t, bulkErr.ObjectErrors[0].StatusCode, 400)
diff --git a/tests/container_test.go b/tests/container_test.go
index 0efc4e6..eed4906 100644
--- a/tests/container_test.go
+++ b/tests/container_test.go
@@ -63,7 +63,6 @@ func TestContainerLifecycle(t *testing.T) {
func TestContainerUpdate(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
-
hdr, err := c.Headers()
expectSuccess(t, err)
expectBool(t, hdr.ObjectCount().Exists(), true)
@@ -80,7 +79,6 @@ func TestContainerUpdate(t *testing.T) {
expectSuccess(t, err)
expectUint64(t, hdr.BytesUsedQuota().Get(), 42)
expectUint64(t, hdr.ObjectCountQuota().Get(), 23)
-
})
}
diff --git a/tests/field_test.go b/tests/field_test.go
index c8dcf7f..cd27c99 100644
--- a/tests/field_test.go
+++ b/tests/field_test.go
@@ -70,7 +70,7 @@ func TestFieldTimestamp(t *testing.T) {
expectBool(t, hdr.CreatedAt().Exists(), true)
actual := float64(hdr.CreatedAt().Get().UnixNano()) / 1e9
- expected, _ := strconv.ParseFloat(hdr.Headers["X-Timestamp"], 64)
+ expected, _ := strconv.ParseFloat(hdr.Headers["X-Timestamp"], 64) //nolint:errcheck
expectFloat64(t, actual, expected)
})
@@ -100,7 +100,7 @@ func TestFieldHTTPTimestamp(t *testing.T) {
expectBool(t, hdr.UpdatedAt().Exists(), true)
actual := hdr.UpdatedAt().Get()
- expected, _ := http.ParseTime(hdr.Get("Last-Modified"))
+ expected, _ := http.ParseTime(hdr.Get("Last-Modified")) //nolint:errcheck
expectInt64(t, actual.Unix(), expected.Unix())
})
diff --git a/tests/largeobject_test.go b/tests/largeobject_test.go
index 1932741..ed61033 100644
--- a/tests/largeobject_test.go
+++ b/tests/largeobject_test.go
@@ -36,9 +36,8 @@ func foreachLargeObjectStrategy(action func(schwift.LargeObjectStrategy, string)
func TestLargeObjectsBasic(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
foreachLargeObjectStrategy(func(strategy schwift.LargeObjectStrategy, strategyStr string) {
-
obj := c.Object(strategyStr + "-largeobject")
- lo, err := obj.AsLargeObject()
+ _, err := obj.AsLargeObject()
expectError(t, err, schwift.ErrNotLarge.Error())
segment1 := getRandomSegmentContent(128)
@@ -47,7 +46,7 @@ func TestLargeObjectsBasic(t *testing.T) {
segment4 := getRandomSegmentContent(128)
//basic write example
- lo, err = obj.AsNewLargeObject(schwift.SegmentingOptions{
+ lo, err := obj.AsNewLargeObject(schwift.SegmentingOptions{
SegmentContainer: c,
SegmentPrefix: strategyStr + "-segments/",
Strategy: strategy,
@@ -135,7 +134,6 @@ func TestLargeObjectsBasic(t *testing.T) {
Etag: etagOfString(segment4),
},
})
-
})
})
}
@@ -171,7 +169,6 @@ func TestLargeObjectExpiration(t *testing.T) {
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"))
-
})
})
}
@@ -212,7 +209,6 @@ func TestTruncateDuringOverwrite(t *testing.T) {
expectObjectExistence(t, c.Object("segments/0000000000000001"), false)
expectObjectExistence(t, c.Object("segments/0000000000000002"), false)
-
})
})
}
diff --git a/tests/object_test.go b/tests/object_test.go
index 1575a31..2f22b24 100644
--- a/tests/object_test.go
+++ b/tests/object_test.go
@@ -21,7 +21,6 @@ package tests
import (
"bytes"
"io"
- "io/ioutil"
"net/http"
"strings"
"testing"
@@ -63,7 +62,6 @@ func TestObjectLifecycle(t *testing.T) {
func TestObjectUpload(t *testing.T) {
testWithContainer(t, func(c *schwift.Container) {
-
//test upload with bytes.Reader
obj := c.Object("upload1")
err := obj.Upload(bytes.NewReader(objectExampleContent), nil, nil)
@@ -152,7 +150,7 @@ func TestObjectDownload(t *testing.T) {
_, err = reader.Read(buf)
expectSuccess(t, err)
expectString(t, string(buf), string(objectExampleContent[4:8]))
- buf, err = ioutil.ReadAll(reader)
+ buf, err = io.ReadAll(reader)
expectSuccess(t, err)
expectString(t, string(buf), string(objectExampleContent[8:]))
})
diff --git a/tests/shared_test.go b/tests/shared_test.go
index 36404bd..d6271a6 100644
--- a/tests/shared_test.go
+++ b/tests/shared_test.go
@@ -19,7 +19,7 @@
package tests
import (
- "crypto/md5"
+ "crypto/md5" //nolint:gosec // Etag uses md5
"crypto/rand"
"encoding/hex"
"math"
@@ -30,6 +30,7 @@ import (
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth"
"github.com/gophercloud/utils/openstack/clientconfig"
+
"github.com/majewsky/schwift"
"github.com/majewsky/schwift/gopherschwift"
)
@@ -106,7 +107,7 @@ func testWithContainer(t *testing.T, testCode func(c *schwift.Container)) {
////////////////////////////////////////////////////////////////////////////////
func etagOf(buf []byte) string {
- hash := md5.Sum(buf)
+ hash := md5.Sum(buf) //nolint:gosec // Etag uses md5
return hex.EncodeToString(hash[:])
}
@@ -123,7 +124,7 @@ func getRandomName() string {
return hex.EncodeToString(buf[:])
}
-func getRandomSegmentContent(length int) string {
+func getRandomSegmentContent(length int) string { //nolint:unparam
buf := make([]byte, length/2)
_, err := rand.Read(buf)
if err != nil {
@@ -176,17 +177,13 @@ func expectString(t *testing.T, actual, expected string) {
}
}
-func expectError(t *testing.T, actual error, expected string) (ok bool) {
+func expectError(t *testing.T, actual error, expected string) {
t.Helper()
if actual == nil {
t.Errorf("expected error %q, got no error\n", expected)
- return false
- }
- if expected != actual.Error() {
+ } else if expected != actual.Error() {
t.Errorf("expected error %q, got %q instead\n", expected, actual.Error())
- return false
}
- return true
}
func expectSuccess(t *testing.T, actual error) (ok bool) {
@@ -198,7 +195,7 @@ func expectSuccess(t *testing.T, actual error) (ok bool) {
return true
}
-func expectHeaders(t *testing.T, actual map[string]string, expected map[string]string) {
+func expectHeaders(t *testing.T, actual, expected map[string]string) {
t.Helper()
reported := make(map[string]bool)