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

yandex: fix fs.Name()

Nick Craig-Wood6c3bf629a1d7
diff --git a/amazonclouddrive/amazonclouddrive_test.go b/amazonclouddrive/amazonclouddrive_test.go
index 20dad31c1..d35a98659 100644
--- a/amazonclouddrive/amazonclouddrive_test.go
+++ b/amazonclouddrive/amazonclouddrive_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/b2/b2_test.go b/b2/b2_test.go
index 8817d8181..d68bfb12d 100644
--- a/b2/b2_test.go
+++ b/b2/b2_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/crypt/crypt2_test.go b/crypt/crypt2_test.go
index 1c059a802..5ac0a0933 100644
--- a/crypt/crypt2_test.go
+++ b/crypt/crypt2_test.go
@@ -21,6 +21,8 @@ func TestSetup2(t *testing.T) {
// Generic tests for the Fs
func TestInit2(t *testing.T) { fstests.TestInit(t) }
func TestFsString2(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName2(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot2(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty2(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound2(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir2(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/crypt/crypt3_test.go b/crypt/crypt3_test.go
index 605efd480..84d989a0a 100644
--- a/crypt/crypt3_test.go
+++ b/crypt/crypt3_test.go
@@ -21,6 +21,8 @@ func TestSetup3(t *testing.T) {
// Generic tests for the Fs
func TestInit3(t *testing.T) { fstests.TestInit(t) }
func TestFsString3(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName3(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot3(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty3(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound3(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir3(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/crypt/crypt_test.go b/crypt/crypt_test.go
index 613cad365..d684c7580 100644
--- a/crypt/crypt_test.go
+++ b/crypt/crypt_test.go
@@ -21,6 +21,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/drive/drive_test.go b/drive/drive_test.go
index 4f48a2206..7c5fa0820 100644
--- a/drive/drive_test.go
+++ b/drive/drive_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/dropbox/dropbox_test.go b/dropbox/dropbox_test.go
index 3d79893ac..6e39ea6be 100644
--- a/dropbox/dropbox_test.go
+++ b/dropbox/dropbox_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index dea99276a..44453089d 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -52,6 +52,7 @@ var (
dumpHeaders = flag.Bool("dump-headers", false, "Dump HTTP headers - may contain sensitive info")
dumpBodies = flag.Bool("dump-bodies", false, "Dump HTTP headers and bodies - may contain sensitive info")
overrideRemote = flag.String("remote", "", "Set this to override the default remote name (eg s3:)")
+ isLocalRemote bool
)
// ExtraConfigItem describes a config item added on the fly while testing
@@ -88,6 +89,7 @@ func TestInit(t *testing.T) {
if RemoteName == "" {
RemoteName, err = fstest.LocalRemote()
require.NoError(t, err)
+ isLocalRemote = true
}
subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(RemoteName)
require.NoError(t, err)
@@ -125,7 +127,29 @@ func skipIfNotListR(t *testing.T) func() {
func TestFsString(t *testing.T) {
skipIfNotOk(t)
str := remote.String()
- require.NotEqual(t, str, "")
+ require.NotEqual(t, "", str)
+}
+
+// TestFsName tests the Name method
+func TestFsName(t *testing.T) {
+ skipIfNotOk(t)
+ got := remote.Name()
+ want := RemoteName
+ if isLocalRemote {
+ want = "local:"
+ }
+ require.Equal(t, want, got+":")
+}
+
+// TestFsRoot tests the Root method
+func TestFsRoot(t *testing.T) {
+ skipIfNotOk(t)
+ name := remote.Name() + ":"
+ root := remote.Root()
+ if isLocalRemote {
+ name = ""
+ }
+ require.Equal(t, subRemoteName, name+root)
}
// TestFsRmdirEmpty tests deleting an empty directory
diff --git a/ftp/ftp_test.go b/ftp/ftp_test.go
index b3e62e023..e09b67f13 100644
--- a/ftp/ftp_test.go
+++ b/ftp/ftp_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/googlecloudstorage/googlecloudstorage_test.go b/googlecloudstorage/googlecloudstorage_test.go
index 57e18b062..1a3b8f21c 100644
--- a/googlecloudstorage/googlecloudstorage_test.go
+++ b/googlecloudstorage/googlecloudstorage_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/hubic/hubic_test.go b/hubic/hubic_test.go
index a20e76920..acb65b52a 100644
--- a/hubic/hubic_test.go
+++ b/hubic/hubic_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/local/local_test.go b/local/local_test.go
index b14acb473..d67b5072b 100644
--- a/local/local_test.go
+++ b/local/local_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/onedrive/onedrive_test.go b/onedrive/onedrive_test.go
index ff1e504ab..d0a6c7187 100644
--- a/onedrive/onedrive_test.go
+++ b/onedrive/onedrive_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/s3/s3_test.go b/s3/s3_test.go
index 45ea9d6d8..1918322a4 100644
--- a/s3/s3_test.go
+++ b/s3/s3_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/sftp/sftp_test.go b/sftp/sftp_test.go
index 8e81a6b75..360b48ff8 100644
--- a/sftp/sftp_test.go
+++ b/sftp/sftp_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/swift/swift_test.go b/swift/swift_test.go
index 1190a0f14..6e7370402 100644
--- a/swift/swift_test.go
+++ b/swift/swift_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }
diff --git a/yandex/yandex.go b/yandex/yandex.go
index f71a480c6..b923e031f 100644
--- a/yandex/yandex.go
+++ b/yandex/yandex.go
@@ -130,7 +130,8 @@ func NewFs(name, root string) (fs.Fs, error) {
yandexDisk := yandex.NewClient(token.AccessToken, fs.Config.Client())
f := &Fs{
- yd: yandexDisk,
+ name: name,
+ yd: yandexDisk,
}
f.features = (&fs.Features{ReadMimeType: true, WriteMimeType: true}).Fill(f)
f.setRoot(root)
diff --git a/yandex/yandex_test.go b/yandex/yandex_test.go
index 683f48dd3..34189e908 100644
--- a/yandex/yandex_test.go
+++ b/yandex/yandex_test.go
@@ -20,6 +20,8 @@ func TestSetup(t *testing.T) {
// Generic tests for the Fs
func TestInit(t *testing.T) { fstests.TestInit(t) }
func TestFsString(t *testing.T) { fstests.TestFsString(t) }
+func TestFsName(t *testing.T) { fstests.TestFsName(t) }
+func TestFsRoot(t *testing.T) { fstests.TestFsRoot(t) }
func TestFsRmdirEmpty(t *testing.T) { fstests.TestFsRmdirEmpty(t) }
func TestFsRmdirNotFound(t *testing.T) { fstests.TestFsRmdirNotFound(t) }
func TestFsMkdir(t *testing.T) { fstests.TestFsMkdir(t) }