"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
fstest/mockobject: add SetFs method so it can have a valid Fs() #3419
Nick Craig-Woodec8e0a6c584a
diff --git a/fstest/mockobject/mockobject.go b/fstest/mockobject/mockobject.goindex 095508723..3f55e4d7c 100644--- a/fstest/mockobject/mockobject.go+++ b/fstest/mockobject/mockobject.go@@ -93,22 +93,37 @@ const (// SeekModes contains all valid SeekMode'svar SeekModes = []SeekMode{SeekModeNone, SeekModeRegular, SeekModeRange}-type contentMockObject struct {+// ContentMockObject mocks an fs.Object and has content+type ContentMockObject struct {Objectcontent []byteseekMode SeekMode+ f fs.Fs}// WithContent returns a fs.Object with the given content.-func (o Object) WithContent(content []byte, mode SeekMode) fs.Object {- return &contentMockObject{+func (o Object) WithContent(content []byte, mode SeekMode) *ContentMockObject {+ return &ContentMockObject{Object: o,content: content,seekMode: mode,}}-func (o *contentMockObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) {+// SetFs sets the return value of the Fs() call+func (o *ContentMockObject) SetFs(f fs.Fs) {+ o.f = f+}++// Fs returns read only access to the Fs that this object is part of+//+// This is nil unless SetFs has been called+func (o *ContentMockObject) Fs() fs.Info {+ return o.f+}++// Open opens the file for read. Call Close() on the returned io.ReadCloser+func (o *ContentMockObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) {var offset, limit int64 = 0, -1for _, option := range options {switch x := option.(type) {@@ -147,7 +162,9 @@ func (o *contentMockObject) Open(ctx context.Context, options ...fs.OpenOption)return nil, errors.New(o.seekMode.String())}}-func (o *contentMockObject) Size() int64 {++// Size returns the size of the file+func (o *ContentMockObject) Size() int64 {return int64(len(o.content))}