Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fstest: calculate hashes for uploaded test files to fix minio integration tests

Nick Craig-Wood66347aff2a6e
diff --git a/fstest/run.go b/fstest/run.go
index 5267ca388..9394d3785 100644
--- a/fstest/run.go
+++ b/fstest/run.go
@@ -41,6 +41,7 @@ import (
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/cache"
"github.com/rclone/rclone/fs/fserrors"
+ "github.com/rclone/rclone/fs/hash"
"github.com/rclone/rclone/fs/object"
"github.com/rclone/rclone/fs/walk"
"github.com/stretchr/testify/assert"
@@ -252,10 +253,22 @@ func (r *Run) WriteObjectTo(ctx context.Context, f fs.Fs, remote, content string
}
}
r.Mkdir(ctx, f)
+
+ // caclulate all hashes f supports for content
+ hash, err := hash.NewMultiHasherTypes(f.Hashes())
+ if err != nil {
+ r.Fatalf("Failed to make new multi hasher: %v", err)
+ }
+ _, err = hash.Write([]byte(content))
+ if err != nil {
+ r.Fatalf("Failed to make write to hash: %v", err)
+ }
+ hashSums := hash.Sums()
+
const maxTries = 10
for tries := 1; ; tries++ {
in := bytes.NewBufferString(content)
- objinfo := object.NewStaticObjectInfo(remote, modTime, int64(len(content)), true, nil, nil)
+ objinfo := object.NewStaticObjectInfo(remote, modTime, int64(len(content)), true, hashSums, nil)
_, err := put(ctx, in, objinfo)
if err == nil {
break