From 0fa700b3cf2af6860fce96861188bb2a68c15d41 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 7 Apr 2018 18:48:11 +0100 Subject: [PATCH] Make integration tests use go1.7+ nested tests #2154 * Removed generated code and code generator * Updated docs on how to write integration tests * Tidied up the actual integration tests --- CONTRIBUTING.md | 3 +- Makefile | 3 - .../amazonclouddrive/amazonclouddrive_test.go | 65 +- backend/azureblob/azureblob_test.go | 71 +- backend/b2/b2_test.go | 71 +- backend/box/box_test.go | 71 +- backend/cache/cache_test.go | 71 +- backend/crypt/crypt2_test.go | 77 - backend/crypt/crypt3_test.go | 77 - backend/crypt/crypt_config_test.go | 34 - backend/crypt/crypt_test.go | 113 +- backend/drive/drive_test.go | 71 +- backend/dropbox/dropbox_test.go | 71 +- backend/ftp/ftp_test.go | 71 +- .../googlecloudstorage_test.go | 71 +- backend/hubic/hubic_test.go | 71 +- backend/local/local_test.go | 71 +- backend/onedrive/onedrive_test.go | 71 +- backend/pcloud/pcloud_test.go | 71 +- backend/qingstor/qingstor_test.go | 71 +- backend/s3/s3_test.go | 71 +- backend/sftp/sftp_test.go | 71 +- backend/swift/swift_test.go | 71 +- backend/webdav/webdav_test.go | 71 +- backend/yandex/yandex_test.go | 71 +- fstest/fstests/fstests.go | 1923 +++++++++-------- fstest/fstests/gen_tests.go | 171 -- 27 files changed, 1129 insertions(+), 2615 deletions(-) delete mode 100644 backend/crypt/crypt2_test.go delete mode 100644 backend/crypt/crypt3_test.go delete mode 100644 backend/crypt/crypt_config_test.go delete mode 100644 fstest/fstests/gen_tests.go diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a73f5cad..a57f31142 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -303,8 +303,7 @@ Getting going Unit tests * Create a config entry called `TestRemote` for the unit tests to use - * Add your fs to the end of `fstest/fstests/gen_tests.go` - * generate `backend/remote/remote_test.go` unit tests `cd fstest/fstests; go generate` + * Create a `backend/remote/remote_test.go` - copy and adjust your example remote * Make sure all tests pass with `go test -v` Integration tests diff --git a/Makefile b/Makefile index 4e350f967..f262bdce3 100644 --- a/Makefile +++ b/Makefile @@ -193,9 +193,6 @@ startdev: echo -e "package fs\n\n// Version of rclone\nvar Version = \"$(LAST_TAG)-DEV\"\n" | gofmt > fs/version.go git commit -m "Start $(LAST_TAG)-DEV development" fs/version.go -gen_tests: - cd fstest/fstests && go generate - winzip: zip -9 rclone-$(TAG).zip rclone.exe diff --git a/backend/amazonclouddrive/amazonclouddrive_test.go b/backend/amazonclouddrive/amazonclouddrive_test.go index 2a581aec9..6298b930b 100644 --- a/backend/amazonclouddrive/amazonclouddrive_test.go +++ b/backend/amazonclouddrive/amazonclouddrive_test.go @@ -1,7 +1,4 @@ // Test AmazonCloudDrive filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests // +build acd @@ -15,65 +12,9 @@ import ( "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { fstests.NilObject = fs.Object((*amazonclouddrive.Object)(nil)) fstests.RemoteName = "TestAmazonCloudDrive:" + fstests.Run(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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/azureblob/azureblob_test.go b/backend/azureblob/azureblob_test.go index 8b9a3ef7d..07a2638c3 100644 --- a/backend/azureblob/azureblob_test.go +++ b/backend/azureblob/azureblob_test.go @@ -1,76 +1,17 @@ // Test AzureBlob filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package azureblob_test import ( "testing" "github.com/ncw/rclone/backend/azureblob" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*azureblob.Object)(nil)) - fstests.RemoteName = "TestAzureBlob:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestAzureBlob:", + NilObject: (*azureblob.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/b2/b2_test.go b/backend/b2/b2_test.go index 8397c8697..b51d68e91 100644 --- a/backend/b2/b2_test.go +++ b/backend/b2/b2_test.go @@ -1,76 +1,17 @@ // Test B2 filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package b2_test import ( "testing" "github.com/ncw/rclone/backend/b2" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*b2.Object)(nil)) - fstests.RemoteName = "TestB2:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestB2:", + NilObject: (*b2.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/box/box_test.go b/backend/box/box_test.go index 83d09fc5d..8355e7ca6 100644 --- a/backend/box/box_test.go +++ b/backend/box/box_test.go @@ -1,76 +1,17 @@ // Test Box filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package box_test import ( "testing" "github.com/ncw/rclone/backend/box" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*box.Object)(nil)) - fstests.RemoteName = "TestBox:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestBox:", + NilObject: (*box.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/cache/cache_test.go b/backend/cache/cache_test.go index c1d207428..f0d29a267 100644 --- a/backend/cache/cache_test.go +++ b/backend/cache/cache_test.go @@ -1,7 +1,4 @@ // Test Cache filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests // +build !plan9 @@ -12,69 +9,13 @@ import ( "github.com/ncw/rclone/backend/cache" _ "github.com/ncw/rclone/backend/local" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*cache.Object)(nil)) - fstests.RemoteName = "TestCache:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestCache:", + NilObject: (*cache.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/crypt/crypt2_test.go b/backend/crypt/crypt2_test.go deleted file mode 100644 index db5987596..000000000 --- a/backend/crypt/crypt2_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// Test Crypt filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests -package crypt_test - -import ( - "testing" - - "github.com/ncw/rclone/backend/crypt" - _ "github.com/ncw/rclone/backend/local" - "github.com/ncw/rclone/fs" - "github.com/ncw/rclone/fstest/fstests" -) - -func TestSetup2(t *testing.T) { - fstests.NilObject = fs.Object((*crypt.Object)(nil)) - fstests.RemoteName = "TestCrypt2:" -} - -// 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) } -func TestFsMkdirRmdirSubdir2(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty2(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty2(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty2(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound2(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile12(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError2(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile22(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile12(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile22(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile22(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot2(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot2(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir2(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir2(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel22(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel22(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile12(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject2(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and22(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir2(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy2(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove2(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove2(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull2(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision2(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify2(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString2(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs2(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote2(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes2(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime2(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType2(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime2(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize2(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen2(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek2(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange2(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead2(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate2(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable2(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile2(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound2(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink2(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove2(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream2(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge2(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal2(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise2(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/crypt/crypt3_test.go b/backend/crypt/crypt3_test.go deleted file mode 100644 index 38d175959..000000000 --- a/backend/crypt/crypt3_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// Test Crypt filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests -package crypt_test - -import ( - "testing" - - "github.com/ncw/rclone/backend/crypt" - _ "github.com/ncw/rclone/backend/local" - "github.com/ncw/rclone/fs" - "github.com/ncw/rclone/fstest/fstests" -) - -func TestSetup3(t *testing.T) { - fstests.NilObject = fs.Object((*crypt.Object)(nil)) - fstests.RemoteName = "TestCrypt3:" -} - -// 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) } -func TestFsMkdirRmdirSubdir3(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty3(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty3(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty3(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound3(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile13(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError3(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile23(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile13(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile23(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile23(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot3(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot3(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir3(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir3(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel23(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel23(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile13(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject3(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and23(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir3(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy3(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove3(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove3(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull3(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision3(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify3(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString3(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs3(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote3(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes3(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime3(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType3(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime3(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize3(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen3(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek3(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange3(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead3(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate3(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable3(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile3(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound3(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink3(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove3(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream3(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge3(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal3(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise3(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/crypt/crypt_config_test.go b/backend/crypt/crypt_config_test.go deleted file mode 100644 index b6725a5f8..000000000 --- a/backend/crypt/crypt_config_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package crypt_test - -import ( - "os" - "path/filepath" - - "github.com/ncw/rclone/fs/config/obscure" - "github.com/ncw/rclone/fstest/fstests" -) - -// Create the TestCrypt: remote -func init() { - tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-standard") - name := "TestCrypt" - tempdir2 := filepath.Join(os.TempDir(), "rclone-crypt-test-off") - name2 := name + "2" - tempdir3 := filepath.Join(os.TempDir(), "rclone-crypt-test-obfuscate") - name3 := name + "3" - fstests.ExtraConfig = []fstests.ExtraConfigItem{ - {Name: name, Key: "type", Value: "crypt"}, - {Name: name, Key: "remote", Value: tempdir}, - {Name: name, Key: "password", Value: obscure.MustObscure("potato")}, - {Name: name, Key: "filename_encryption", Value: "standard"}, - {Name: name2, Key: "type", Value: "crypt"}, - {Name: name2, Key: "remote", Value: tempdir2}, - {Name: name2, Key: "password", Value: obscure.MustObscure("potato2")}, - {Name: name2, Key: "filename_encryption", Value: "off"}, - {Name: name3, Key: "type", Value: "crypt"}, - {Name: name3, Key: "remote", Value: tempdir3}, - {Name: name3, Key: "password", Value: obscure.MustObscure("potato2")}, - {Name: name3, Key: "filename_encryption", Value: "obfuscate"}, - } - fstests.SkipBadWindowsCharacters[name3+":"] = true -} diff --git a/backend/crypt/crypt_test.go b/backend/crypt/crypt_test.go index 6eb8bcb73..1fb14ab9b 100644 --- a/backend/crypt/crypt_test.go +++ b/backend/crypt/crypt_test.go @@ -1,77 +1,62 @@ // Test Crypt filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package crypt_test import ( + "os" + "path/filepath" "testing" "github.com/ncw/rclone/backend/crypt" _ "github.com/ncw/rclone/backend/local" - "github.com/ncw/rclone/fs" + "github.com/ncw/rclone/fs/config/obscure" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*crypt.Object)(nil)) - fstests.RemoteName = "TestCrypt:" +// TestStandard runs integration tests against the remote +func TestStandard(t *testing.T) { + tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-standard") + name := "TestCrypt" + fstests.Run(t, &fstests.Opt{ + RemoteName: name + ":", + NilObject: (*crypt.Object)(nil), + ExtraConfig: []fstests.ExtraConfigItem{ + {Name: name, Key: "type", Value: "crypt"}, + {Name: name, Key: "remote", Value: tempdir}, + {Name: name, Key: "password", Value: obscure.MustObscure("potato")}, + {Name: name, Key: "filename_encryption", Value: "standard"}, + }, + }) } -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } +// TestOff runs integration tests against the remote +func TestOff(t *testing.T) { + tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-off") + name := "TestCrypt2" + fstests.Run(t, &fstests.Opt{ + RemoteName: name + ":", + NilObject: (*crypt.Object)(nil), + ExtraConfig: []fstests.ExtraConfigItem{ + {Name: name, Key: "type", Value: "crypt"}, + {Name: name, Key: "remote", Value: tempdir}, + {Name: name, Key: "password", Value: obscure.MustObscure("potato2")}, + {Name: name, Key: "filename_encryption", Value: "off"}, + }, + }) +} + +// TestObfuscate runs integration tests against the remote +func TestObfuscate(t *testing.T) { + tempdir := filepath.Join(os.TempDir(), "rclone-crypt-test-obfuscate") + name := "TestCrypt3" + fstests.Run(t, &fstests.Opt{ + RemoteName: name + ":", + NilObject: (*crypt.Object)(nil), + ExtraConfig: []fstests.ExtraConfigItem{ + {Name: name, Key: "type", Value: "crypt"}, + {Name: name, Key: "remote", Value: tempdir}, + {Name: name, Key: "password", Value: obscure.MustObscure("potato2")}, + {Name: name, Key: "filename_encryption", Value: "obfuscate"}, + }, + SkipBadWindowsCharacters: true, + }) +} diff --git a/backend/drive/drive_test.go b/backend/drive/drive_test.go index 3b644993f..ec3a612c7 100644 --- a/backend/drive/drive_test.go +++ b/backend/drive/drive_test.go @@ -1,76 +1,17 @@ // Test Drive filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package drive_test import ( "testing" "github.com/ncw/rclone/backend/drive" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*drive.Object)(nil)) - fstests.RemoteName = "TestDrive:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestDrive:", + NilObject: (*drive.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/dropbox/dropbox_test.go b/backend/dropbox/dropbox_test.go index 46d298484..e4f9bb6b9 100644 --- a/backend/dropbox/dropbox_test.go +++ b/backend/dropbox/dropbox_test.go @@ -1,76 +1,17 @@ // Test Dropbox filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package dropbox_test import ( "testing" "github.com/ncw/rclone/backend/dropbox" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*dropbox.Object)(nil)) - fstests.RemoteName = "TestDropbox:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestDropbox:", + NilObject: (*dropbox.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/ftp/ftp_test.go b/backend/ftp/ftp_test.go index 86262cf12..bb71e7382 100644 --- a/backend/ftp/ftp_test.go +++ b/backend/ftp/ftp_test.go @@ -1,76 +1,17 @@ // Test FTP filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package ftp_test import ( "testing" "github.com/ncw/rclone/backend/ftp" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*ftp.Object)(nil)) - fstests.RemoteName = "TestFTP:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestFTP:", + NilObject: (*ftp.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/googlecloudstorage/googlecloudstorage_test.go b/backend/googlecloudstorage/googlecloudstorage_test.go index 15fe2a9f8..5541e110c 100644 --- a/backend/googlecloudstorage/googlecloudstorage_test.go +++ b/backend/googlecloudstorage/googlecloudstorage_test.go @@ -1,76 +1,17 @@ // Test GoogleCloudStorage filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package googlecloudstorage_test import ( "testing" "github.com/ncw/rclone/backend/googlecloudstorage" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*googlecloudstorage.Object)(nil)) - fstests.RemoteName = "TestGoogleCloudStorage:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestGoogleCloudStorage:", + NilObject: (*googlecloudstorage.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/hubic/hubic_test.go b/backend/hubic/hubic_test.go index 0987a0fe0..8176f0a48 100644 --- a/backend/hubic/hubic_test.go +++ b/backend/hubic/hubic_test.go @@ -1,76 +1,17 @@ // Test Hubic filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package hubic_test import ( "testing" "github.com/ncw/rclone/backend/hubic" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*hubic.Object)(nil)) - fstests.RemoteName = "TestHubic:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestHubic:", + NilObject: (*hubic.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/local/local_test.go b/backend/local/local_test.go index e8c3ebd58..81f9f6e21 100644 --- a/backend/local/local_test.go +++ b/backend/local/local_test.go @@ -1,76 +1,17 @@ // Test Local filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package local_test import ( "testing" "github.com/ncw/rclone/backend/local" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*local.Object)(nil)) - fstests.RemoteName = "" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "", + NilObject: (*local.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/onedrive/onedrive_test.go b/backend/onedrive/onedrive_test.go index 070aa58d6..07eccc017 100644 --- a/backend/onedrive/onedrive_test.go +++ b/backend/onedrive/onedrive_test.go @@ -1,76 +1,17 @@ // Test OneDrive filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package onedrive_test import ( "testing" "github.com/ncw/rclone/backend/onedrive" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*onedrive.Object)(nil)) - fstests.RemoteName = "TestOneDrive:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestOneDrive:", + NilObject: (*onedrive.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/pcloud/pcloud_test.go b/backend/pcloud/pcloud_test.go index b49d98400..243ecb3ac 100644 --- a/backend/pcloud/pcloud_test.go +++ b/backend/pcloud/pcloud_test.go @@ -1,76 +1,17 @@ // Test Pcloud filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package pcloud_test import ( "testing" "github.com/ncw/rclone/backend/pcloud" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*pcloud.Object)(nil)) - fstests.RemoteName = "TestPcloud:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestPcloud:", + NilObject: (*pcloud.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/qingstor/qingstor_test.go b/backend/qingstor/qingstor_test.go index 78d416a20..585df5196 100644 --- a/backend/qingstor/qingstor_test.go +++ b/backend/qingstor/qingstor_test.go @@ -1,7 +1,4 @@ // Test QingStor filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests // +build !plan9 @@ -11,69 +8,13 @@ import ( "testing" "github.com/ncw/rclone/backend/qingstor" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*qingstor.Object)(nil)) - fstests.RemoteName = "TestQingStor:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestQingStor:", + NilObject: (*qingstor.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/s3/s3_test.go b/backend/s3/s3_test.go index 718ce0d26..d1d2d4c37 100644 --- a/backend/s3/s3_test.go +++ b/backend/s3/s3_test.go @@ -1,76 +1,17 @@ // Test S3 filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package s3_test import ( "testing" "github.com/ncw/rclone/backend/s3" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*s3.Object)(nil)) - fstests.RemoteName = "TestS3:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestS3:", + NilObject: (*s3.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/sftp/sftp_test.go b/backend/sftp/sftp_test.go index 1df429aaf..824d99bc6 100644 --- a/backend/sftp/sftp_test.go +++ b/backend/sftp/sftp_test.go @@ -1,7 +1,4 @@ // Test Sftp filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests // +build !plan9,go1.8 @@ -11,69 +8,13 @@ import ( "testing" "github.com/ncw/rclone/backend/sftp" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*sftp.Object)(nil)) - fstests.RemoteName = "TestSftp:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestSftp:", + NilObject: (*sftp.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/swift/swift_test.go b/backend/swift/swift_test.go index d0d312863..eec0b99cb 100644 --- a/backend/swift/swift_test.go +++ b/backend/swift/swift_test.go @@ -1,76 +1,17 @@ // Test Swift filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package swift_test import ( "testing" "github.com/ncw/rclone/backend/swift" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*swift.Object)(nil)) - fstests.RemoteName = "TestSwift:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestSwift:", + NilObject: (*swift.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/webdav/webdav_test.go b/backend/webdav/webdav_test.go index 825d26d2b..a4264fa45 100644 --- a/backend/webdav/webdav_test.go +++ b/backend/webdav/webdav_test.go @@ -1,76 +1,17 @@ // Test Webdav filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package webdav_test import ( "testing" "github.com/ncw/rclone/backend/webdav" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*webdav.Object)(nil)) - fstests.RemoteName = "TestWebdav:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestWebdav:", + NilObject: (*webdav.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/backend/yandex/yandex_test.go b/backend/yandex/yandex_test.go index 30c57314d..4dcf976ab 100644 --- a/backend/yandex/yandex_test.go +++ b/backend/yandex/yandex_test.go @@ -1,76 +1,17 @@ // Test Yandex filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: make gen_tests package yandex_test import ( "testing" "github.com/ncw/rclone/backend/yandex" - "github.com/ncw/rclone/fs" "github.com/ncw/rclone/fstest/fstests" ) -func TestSetup(t *testing.T) { - fstests.NilObject = fs.Object((*yandex.Object)(nil)) - fstests.RemoteName = "TestYandex:" +// TestIntegration runs integration tests against the remote +func TestIntegration(t *testing.T) { + fstests.Run(t, &fstests.Opt{ + RemoteName: "TestYandex:", + NilObject: (*yandex.Object)(nil), + }) } - -// 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) } -func TestFsMkdirRmdirSubdir(t *testing.T) { fstests.TestFsMkdirRmdirSubdir(t) } -func TestFsListEmpty(t *testing.T) { fstests.TestFsListEmpty(t) } -func TestFsListDirEmpty(t *testing.T) { fstests.TestFsListDirEmpty(t) } -func TestFsListRDirEmpty(t *testing.T) { fstests.TestFsListRDirEmpty(t) } -func TestFsNewObjectNotFound(t *testing.T) { fstests.TestFsNewObjectNotFound(t) } -func TestFsPutFile1(t *testing.T) { fstests.TestFsPutFile1(t) } -func TestFsPutError(t *testing.T) { fstests.TestFsPutError(t) } -func TestFsPutFile2(t *testing.T) { fstests.TestFsPutFile2(t) } -func TestFsUpdateFile1(t *testing.T) { fstests.TestFsUpdateFile1(t) } -func TestFsListDirFile2(t *testing.T) { fstests.TestFsListDirFile2(t) } -func TestFsListRDirFile2(t *testing.T) { fstests.TestFsListRDirFile2(t) } -func TestFsListDirRoot(t *testing.T) { fstests.TestFsListDirRoot(t) } -func TestFsListRDirRoot(t *testing.T) { fstests.TestFsListRDirRoot(t) } -func TestFsListSubdir(t *testing.T) { fstests.TestFsListSubdir(t) } -func TestFsListRSubdir(t *testing.T) { fstests.TestFsListRSubdir(t) } -func TestFsListLevel2(t *testing.T) { fstests.TestFsListLevel2(t) } -func TestFsListRLevel2(t *testing.T) { fstests.TestFsListRLevel2(t) } -func TestFsListFile1(t *testing.T) { fstests.TestFsListFile1(t) } -func TestFsNewObject(t *testing.T) { fstests.TestFsNewObject(t) } -func TestFsListFile1and2(t *testing.T) { fstests.TestFsListFile1and2(t) } -func TestFsNewObjectDir(t *testing.T) { fstests.TestFsNewObjectDir(t) } -func TestFsCopy(t *testing.T) { fstests.TestFsCopy(t) } -func TestFsMove(t *testing.T) { fstests.TestFsMove(t) } -func TestFsDirMove(t *testing.T) { fstests.TestFsDirMove(t) } -func TestFsRmdirFull(t *testing.T) { fstests.TestFsRmdirFull(t) } -func TestFsPrecision(t *testing.T) { fstests.TestFsPrecision(t) } -func TestFsChangeNotify(t *testing.T) { fstests.TestFsChangeNotify(t) } -func TestObjectString(t *testing.T) { fstests.TestObjectString(t) } -func TestObjectFs(t *testing.T) { fstests.TestObjectFs(t) } -func TestObjectRemote(t *testing.T) { fstests.TestObjectRemote(t) } -func TestObjectHashes(t *testing.T) { fstests.TestObjectHashes(t) } -func TestObjectModTime(t *testing.T) { fstests.TestObjectModTime(t) } -func TestObjectMimeType(t *testing.T) { fstests.TestObjectMimeType(t) } -func TestObjectSetModTime(t *testing.T) { fstests.TestObjectSetModTime(t) } -func TestObjectSize(t *testing.T) { fstests.TestObjectSize(t) } -func TestObjectOpen(t *testing.T) { fstests.TestObjectOpen(t) } -func TestObjectOpenSeek(t *testing.T) { fstests.TestObjectOpenSeek(t) } -func TestObjectOpenRange(t *testing.T) { fstests.TestObjectOpenRange(t) } -func TestObjectPartialRead(t *testing.T) { fstests.TestObjectPartialRead(t) } -func TestObjectUpdate(t *testing.T) { fstests.TestObjectUpdate(t) } -func TestObjectStorable(t *testing.T) { fstests.TestObjectStorable(t) } -func TestFsIsFile(t *testing.T) { fstests.TestFsIsFile(t) } -func TestFsIsFileNotFound(t *testing.T) { fstests.TestFsIsFileNotFound(t) } -func TestPublicLink(t *testing.T) { fstests.TestPublicLink(t) } -func TestObjectRemove(t *testing.T) { fstests.TestObjectRemove(t) } -func TestFsPutStream(t *testing.T) { fstests.TestFsPutStream(t) } -func TestObjectPurge(t *testing.T) { fstests.TestObjectPurge(t) } -func TestInternal(t *testing.T) { fstests.TestInternal(t) } -func TestFinalise(t *testing.T) { fstests.TestFinalise(t) } diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go index 91b281fce..824aafc19 100644 --- a/fstest/fstests/fstests.go +++ b/fstest/fstests/fstests.go @@ -1,10 +1,7 @@ -// Package fstests provides generic tests for testing the Fs and Object interfaces -// -// Run go generate to write the tests for the remotes +// Package fstests provides generic integration tests for the Fs and +// Object interfaces package fstests -//go:generate go run gen_tests.go - import ( "bytes" "fmt" @@ -31,32 +28,6 @@ import ( "github.com/stretchr/testify/require" ) -var ( - remote fs.Fs - // RemoteName should be set to the name of the remote for testing - RemoteName = "" - subRemoteName = "" - subRemoteLeaf = "" - // NilObject should be set to a nil Object from the Fs under test - NilObject fs.Object - // ExtraConfig is for adding config to a remote - ExtraConfig = []ExtraConfigItem{} - // SkipBadWindowsCharacters skips unusable characters for windows if set - SkipBadWindowsCharacters = map[string]bool{} - file1 = fstest.Item{ - ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"), - Path: "file name.txt", - } - file1Contents = "" - file2 = fstest.Item{ - ModTime: fstest.Time("2001-02-03T04:05:10.123123123Z"), - Path: `hello? sausage/êé/Hello, 世界/ " ' @ < > & ? + ≠/z.txt`, - WinPath: `hello_ sausage/êé/Hello, 世界/ _ ' @ _ _ & _ + ≠/z.txt`, - } - file2Contents = "" - isLocalRemote bool -) - // InternalTester is an optional interface for Fs which allows to execute internal tests // // This interface should be implemented in 'backend'_internal_test.go and not in 'backend'.go @@ -64,165 +35,6 @@ type InternalTester interface { InternalTest(*testing.T) } -// ExtraConfigItem describes a config item added on the fly while testing -type ExtraConfigItem struct{ Name, Key, Value string } - -// Make the Fs we are testing with, initialising the global variables -// subRemoteName - name of the remote after the TestRemote: -// subRemoteLeaf - a subdirectory to use under that -// remote - the result of fs.NewFs(TestRemote:subRemoteName) -func newFs(t *testing.T) { - var err error - subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(RemoteName) - require.NoError(t, err) - remote, err = fs.NewFs(subRemoteName) - if err == fs.ErrorNotFoundInConfigFile { - t.Logf("Didn't find %q in config file - skipping tests", RemoteName) - return - } - require.NoError(t, err, fmt.Sprintf("unexpected error: %v", err)) -} - -// TestInit tests basic intitialisation -func TestInit(t *testing.T) { - var err error - - // Remove bad characters from Windows file name if set - if SkipBadWindowsCharacters[RemoteName] { - t.Logf("Removing bad windows characters from test file") - file2.Path = winPath(file2.Path) - } - - fstest.Initialise() - - // Set extra config if supplied - for _, item := range ExtraConfig { - config.FileSet(item.Name, item.Key, item.Value) - } - if *fstest.RemoteName != "" { - RemoteName = *fstest.RemoteName - } - t.Logf("Using remote %q", RemoteName) - if RemoteName == "" { - RemoteName, err = fstest.LocalRemote() - require.NoError(t, err) - isLocalRemote = true - } - - newFs(t) - - skipIfNotOk(t) - - err = remote.Mkdir("") - require.NoError(t, err) - fstest.CheckListing(t, remote, []fstest.Item{}) -} - -func skipIfNotOk(t *testing.T) { - if remote == nil { - t.Skipf("WARN: %q not configured", RemoteName) - } -} - -// Skip if remote is not ListR capable, otherwise set the useListR -// flag, returning a function to restore its value -func skipIfNotListR(t *testing.T) func() { - skipIfNotOk(t) - if remote.Features().ListR == nil { - t.Skip("FS has no ListR interface") - } - previous := fs.Config.UseListR - fs.Config.UseListR = true - return func() { - fs.Config.UseListR = previous - } -} - -// TestFsString tests the String method -func TestFsString(t *testing.T) { - skipIfNotOk(t) - str := remote.String() - 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 { - // only check last path element on local - require.Equal(t, filepath.Base(subRemoteName), filepath.Base(root)) - } else { - require.Equal(t, subRemoteName, name+root) - } -} - -// TestFsRmdirEmpty tests deleting an empty directory -func TestFsRmdirEmpty(t *testing.T) { - skipIfNotOk(t) - err := remote.Rmdir("") - require.NoError(t, err) -} - -// TestFsRmdirNotFound tests deleting a non existent directory -func TestFsRmdirNotFound(t *testing.T) { - skipIfNotOk(t) - err := remote.Rmdir("") - assert.Error(t, err, "Expecting error on Rmdir non existent") -} - -// TestFsMkdir tests tests making a directory -func TestFsMkdir(t *testing.T) { - skipIfNotOk(t) - - // Use a new directory here. This is for the container based - // remotes which take time to create and destroy a container - // (eg azure blob) - newFs(t) - - err := remote.Mkdir("") - require.NoError(t, err) - fstest.CheckListing(t, remote, []fstest.Item{}) - - err = remote.Mkdir("") - require.NoError(t, err) -} - -// TestFsMkdirRmdirSubdir tests making and removing a sub directory -func TestFsMkdirRmdirSubdir(t *testing.T) { - skipIfNotOk(t) - dir := "dir/subdir" - err := operations.Mkdir(remote, dir) - require.NoError(t, err) - fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir", "dir/subdir"}, fs.Config.ModifyWindow) - - err = operations.Rmdir(remote, dir) - require.NoError(t, err) - fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir"}, fs.Config.ModifyWindow) - - err = operations.Rmdir(remote, "dir") - require.NoError(t, err) - fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{}, fs.Config.ModifyWindow) -} - -// TestFsListEmpty tests listing an empty directory -func TestFsListEmpty(t *testing.T) { - skipIfNotOk(t) - fstest.CheckListing(t, remote, []fstest.Item{}) -} - // winPath converts a path into a windows safe path func winPath(s string) string { return strings.Map(func(r rune) rune { @@ -254,39 +66,12 @@ func objsToNames(objs []fs.Object) []string { return names } -// TestFsListDirEmpty tests listing the directories from an empty directory -func TestFsListDirEmpty(t *testing.T) { - skipIfNotOk(t) - objs, dirs, err := walk.GetAll(remote, "", true, 1) - require.NoError(t, err) - assert.Equal(t, []string{}, objsToNames(objs)) - assert.Equal(t, []string{}, dirsToNames(dirs)) -} - -// TestFsListRDirEmpty tests listing the directories from an empty directory using ListR -func TestFsListRDirEmpty(t *testing.T) { - defer skipIfNotListR(t)() - TestFsListDirEmpty(t) -} - -// TestFsNewObjectNotFound tests not finding a object -func TestFsNewObjectNotFound(t *testing.T) { - skipIfNotOk(t) - // Object in an existing directory - o, err := remote.NewObject("potato") - assert.Nil(t, o) - assert.Equal(t, fs.ErrorObjectNotFound, err) - // Now try an object in a non existing directory - o, err = remote.NewObject("directory/not/found/potato") - assert.Nil(t, o) - assert.Equal(t, fs.ErrorObjectNotFound, err) -} - -func findObject(t *testing.T, Name string) fs.Object { +// findObject finds the object on the remote +func findObject(t *testing.T, f fs.Fs, Name string) fs.Object { var obj fs.Object var err error for i := 1; i <= *fstest.ListRetries; i++ { - obj, err = remote.NewObject(Name) + obj, err = f.NewObject(Name) if err == nil { break } @@ -297,7 +82,8 @@ func findObject(t *testing.T, Name string) fs.Object { return obj } -func testPut(t *testing.T, file *fstest.Item) string { +// testPut puts file to the remote +func testPut(t *testing.T, f fs.Fs, file *fstest.Item) string { tries := 1 const maxTries = 10 again: @@ -308,7 +94,7 @@ again: file.Size = int64(buf.Len()) obji := object.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil) - obj, err := remote.Put(in, obji) + obj, err := f.Put(in, obji) if err != nil { // Retry if err returned a retry error if fserrors.IsRetryError(err) && tries < maxTries { @@ -321,519 +107,23 @@ again: require.NoError(t, err, fmt.Sprintf("Put error: %v", err)) } file.Hashes = hash.Sums() - file.Check(t, obj, remote.Precision()) + file.Check(t, obj, f.Precision()) // Re-read the object and check again - obj = findObject(t, file.Path) - file.Check(t, obj, remote.Precision()) + obj = findObject(t, f, file.Path) + file.Check(t, obj, f.Precision()) return contents } -// TestFsPutFile1 tests putting a file -func TestFsPutFile1(t *testing.T) { - skipIfNotOk(t) - file1Contents = testPut(t, &file1) -} - +// errorReader just returne an error on Read type errorReader struct { err error } +// Read returns an error immediately func (er errorReader) Read(p []byte) (n int, err error) { return 0, er.err } -// TestFsPutError tests uploading a file where there is an error -// -// It makes sure that aborting a file half way through does not create -// a file on the remote. -func TestFsPutError(t *testing.T) { - skipIfNotOk(t) - - // Read 50 bytes then produce an error - contents := fstest.RandomString(50) - buf := bytes.NewBufferString(contents) - er := &errorReader{errors.New("potato")} - in := io.MultiReader(buf, er) - - obji := object.NewStaticObjectInfo(file2.Path, file2.ModTime, 100, true, nil, nil) - _, err := remote.Put(in, obji) - // assert.Nil(t, obj) - FIXME some remotes return the object even on nil - assert.NotNil(t, err) - - obj, err := remote.NewObject(file2.Path) - assert.Nil(t, obj) - assert.Equal(t, fs.ErrorObjectNotFound, err) -} - -// TestFsPutFile2 tests putting a file into a subdirectory -func TestFsPutFile2(t *testing.T) { - skipIfNotOk(t) - file2Contents = testPut(t, &file2) -} - -// TestFsUpdateFile1 tests updating file1 with new contents -func TestFsUpdateFile1(t *testing.T) { - skipIfNotOk(t) - file1Contents = testPut(t, &file1) - // Note that the next test will check there are no duplicated file names -} - -// TestFsListDirFile2 tests the files are correctly uploaded by doing -// Depth 1 directory listings -func TestFsListDirFile2(t *testing.T) { - skipIfNotOk(t) - list := func(dir string, expectedDirNames, expectedObjNames []string) { - var objNames, dirNames []string - for i := 1; i <= *fstest.ListRetries; i++ { - objs, dirs, err := walk.GetAll(remote, dir, true, 1) - if errors.Cause(err) == fs.ErrorDirNotFound { - objs, dirs, err = walk.GetAll(remote, winPath(dir), true, 1) - } - require.NoError(t, err) - objNames = objsToNames(objs) - dirNames = dirsToNames(dirs) - if len(objNames) >= len(expectedObjNames) && len(dirNames) >= len(expectedDirNames) { - break - } - t.Logf("Sleeping for 1 second for TestFsListDirFile2 eventual consistency: %d/%d", i, *fstest.ListRetries) - time.Sleep(1 * time.Second) - } - assert.Equal(t, expectedDirNames, dirNames) - assert.Equal(t, expectedObjNames, objNames) - } - dir := file2.Path - deepest := true - for dir != "" { - expectedObjNames := []string{} - expectedDirNames := []string{} - child := dir - dir = path.Dir(dir) - if dir == "." { - dir = "" - expectedObjNames = append(expectedObjNames, winPath(file1.Path)) - } - if deepest { - expectedObjNames = append(expectedObjNames, winPath(file2.Path)) - deepest = false - } else { - expectedDirNames = append(expectedDirNames, winPath(child)) - } - list(dir, expectedDirNames, expectedObjNames) - } -} - -// TestFsListRDirFile2 tests the files are correctly uploaded by doing -// Depth 1 directory listings using ListR -func TestFsListRDirFile2(t *testing.T) { - defer skipIfNotListR(t)() - TestFsListDirFile2(t) -} - -// TestFsListDirRoot tests that DirList works in the root -func TestFsListDirRoot(t *testing.T) { - skipIfNotOk(t) - rootRemote, err := fs.NewFs(RemoteName) - require.NoError(t, err) - _, dirs, err := walk.GetAll(rootRemote, "", true, 1) - require.NoError(t, err) - assert.Contains(t, dirsToNames(dirs), subRemoteLeaf, "Remote leaf not found") -} - -// TestFsListRDirRoot tests that DirList works in the root using ListR -func TestFsListRDirRoot(t *testing.T) { - defer skipIfNotListR(t)() - TestFsListDirRoot(t) -} - -// TestFsListSubdir tests List works for a subdirectory -func TestFsListSubdir(t *testing.T) { - skipIfNotOk(t) - fileName := file2.Path - var err error - var objs []fs.Object - var dirs []fs.Directory - for i := 0; i < 2; i++ { - dir, _ := path.Split(fileName) - dir = dir[:len(dir)-1] - objs, dirs, err = walk.GetAll(remote, dir, true, -1) - if err != fs.ErrorDirNotFound { - break - } - fileName = file2.WinPath - } - require.NoError(t, err) - require.Len(t, objs, 1) - assert.Equal(t, fileName, objs[0].Remote()) - require.Len(t, dirs, 0) -} - -// TestFsListRSubdir tests List works for a subdirectory using ListR -func TestFsListRSubdir(t *testing.T) { - defer skipIfNotListR(t)() - TestFsListSubdir(t) -} - -// TestFsListLevel2 tests List works for 2 levels -func TestFsListLevel2(t *testing.T) { - skipIfNotOk(t) - objs, dirs, err := walk.GetAll(remote, "", true, 2) - if err == fs.ErrorLevelNotSupported { - return - } - require.NoError(t, err) - assert.Equal(t, []string{file1.Path}, objsToNames(objs)) - assert.Equal(t, []string{`hello_ sausage`, `hello_ sausage/êé`}, dirsToNames(dirs)) -} - -// TestFsListRLevel2 tests List works for 2 levels using ListR -func TestFsListRLevel2(t *testing.T) { - defer skipIfNotListR(t)() - TestFsListLevel2(t) -} - -// TestFsListFile1 tests file present -func TestFsListFile1(t *testing.T) { - skipIfNotOk(t) - fstest.CheckListing(t, remote, []fstest.Item{file1, file2}) -} - -// TestFsNewObject tests NewObject -func TestFsNewObject(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - file1.Check(t, obj, remote.Precision()) -} - -// TestFsListFile1and2 tests two files present -func TestFsListFile1and2(t *testing.T) { - skipIfNotOk(t) - fstest.CheckListing(t, remote, []fstest.Item{file1, file2}) -} - -// TestFsNewObjectDir tests NewObject on a directory which should produce an error -func TestFsNewObjectDir(t *testing.T) { - skipIfNotOk(t) - dir := path.Dir(file2.Path) - obj, err := remote.NewObject(dir) - assert.Nil(t, obj) - assert.NotNil(t, err) -} - -// TestFsCopy tests Copy -func TestFsCopy(t *testing.T) { - skipIfNotOk(t) - - // Check have Copy - doCopy := remote.Features().Copy - if doCopy == nil { - t.Skip("FS has no Copier interface") - } - - // Test with file2 so have + and ' ' in file name - var file2Copy = file2 - file2Copy.Path += "-copy" - - // do the copy - src := findObject(t, file2.Path) - dst, err := doCopy(src, file2Copy.Path) - if err == fs.ErrorCantCopy { - t.Skip("FS can't copy") - } - require.NoError(t, err, fmt.Sprintf("Error: %#v", err)) - - // check file exists in new listing - fstest.CheckListing(t, remote, []fstest.Item{file1, file2, file2Copy}) - - // Check dst lightly - list above has checked ModTime/Hashes - assert.Equal(t, file2Copy.Path, dst.Remote()) - - // Delete copy - err = dst.Remove() - require.NoError(t, err) - -} - -// TestFsMove tests Move -func TestFsMove(t *testing.T) { - skipIfNotOk(t) - - // Check have Move - doMove := remote.Features().Move - if doMove == nil { - t.Skip("FS has no Mover interface") - } - - // state of files now: - // 1: file name.txt - // 2: hello sausage?/../z.txt - - var file1Move = file1 - var file2Move = file2 - - // check happy path, i.e. no naming conflicts when rename and move are two - // separate operations - file2Move.Path = "other.txt" - file2Move.WinPath = "" - src := findObject(t, file2.Path) - dst, err := doMove(src, file2Move.Path) - if err == fs.ErrorCantMove { - t.Skip("FS can't move") - } - require.NoError(t, err) - // check file exists in new listing - fstest.CheckListing(t, remote, []fstest.Item{file1, file2Move}) - // Check dst lightly - list above has checked ModTime/Hashes - assert.Equal(t, file2Move.Path, dst.Remote()) - // 1: file name.txt - // 2: other.txt - - // Check conflict on "rename, then move" - file1Move.Path = "moveTest/other.txt" - src = findObject(t, file1.Path) - _, err = doMove(src, file1Move.Path) - require.NoError(t, err) - fstest.CheckListing(t, remote, []fstest.Item{file1Move, file2Move}) - // 1: moveTest/other.txt - // 2: other.txt - - // Check conflict on "move, then rename" - src = findObject(t, file1Move.Path) - _, err = doMove(src, file1.Path) - require.NoError(t, err) - fstest.CheckListing(t, remote, []fstest.Item{file1, file2Move}) - // 1: file name.txt - // 2: other.txt - - src = findObject(t, file2Move.Path) - _, err = doMove(src, file2.Path) - require.NoError(t, err) - fstest.CheckListing(t, remote, []fstest.Item{file1, file2}) - // 1: file name.txt - // 2: hello sausage?/../z.txt -} - -// Move src to this remote using server side move operations. -// -// Will only be called if src.Fs().Name() == f.Name() -// -// If it isn't possible then return fs.ErrorCantDirMove -// -// If destination exists then return fs.ErrorDirExists - -// TestFsDirMove tests DirMove -// -// go test -v -run '^Test(Setup|Init|FsMkdir|FsPutFile1|FsPutFile2|FsUpdateFile1|FsDirMove)$ -func TestFsDirMove(t *testing.T) { - skipIfNotOk(t) - - // Check have DirMove - doDirMove := remote.Features().DirMove - if doDirMove == nil { - t.Skip("FS has no DirMover interface") - } - - // Check it can't move onto itself - err := doDirMove(remote, "", "") - require.Equal(t, fs.ErrorDirExists, err) - - // new remote - newRemote, _, removeNewRemote, err := fstest.RandomRemote(RemoteName, false) - require.NoError(t, err) - defer removeNewRemote() - - const newName = "new_name/sub_new_name" - // try the move - err = newRemote.Features().DirMove(remote, "", newName) - require.NoError(t, err) - - // check remotes - // FIXME: Prints errors. - fstest.CheckListing(t, remote, []fstest.Item{}) - file1Copy := file1 - file1Copy.Path = path.Join(newName, file1.Path) - file2Copy := file2 - file2Copy.Path = path.Join(newName, file2.Path) - file2Copy.WinPath = path.Join(newName, file2.WinPath) - fstest.CheckListing(t, newRemote, []fstest.Item{file2Copy, file1Copy}) - - // move it back - err = doDirMove(newRemote, newName, "") - require.NoError(t, err) - - // check remotes - fstest.CheckListing(t, remote, []fstest.Item{file2, file1}) - fstest.CheckListing(t, newRemote, []fstest.Item{}) -} - -// TestFsRmdirFull tests removing a non empty directory -func TestFsRmdirFull(t *testing.T) { - skipIfNotOk(t) - err := remote.Rmdir("") - require.Error(t, err, "Expecting error on RMdir on non empty remote") -} - -// TestFsPrecision tests the Precision of the Fs -func TestFsPrecision(t *testing.T) { - skipIfNotOk(t) - precision := remote.Precision() - if precision == fs.ModTimeNotSupported { - return - } - if precision > time.Second || precision < 0 { - t.Fatalf("Precision out of range %v", precision) - } - // FIXME check expected precision -} - -// TestFsChangeNotify tests that changes are properly -// propagated -// -// go test -v -remote TestDrive: -run '^Test(Setup|Init|FsChangeNotify)$' -verbose -func TestFsChangeNotify(t *testing.T) { - skipIfNotOk(t) - - // Check have ChangeNotify - doChangeNotify := remote.Features().ChangeNotify - if doChangeNotify == nil { - t.Skip("FS has no ChangeNotify interface") - } - - err := operations.Mkdir(remote, "dir") - require.NoError(t, err) - - dirChanges := []string{} - objChanges := []string{} - quitChannel := doChangeNotify(func(x string, e fs.EntryType) { - fs.Debugf(nil, "doChangeNotify(%q, %+v)", x, e) - if strings.HasPrefix(x, file1.Path[:5]) || strings.HasPrefix(x, file2.Path[:5]) { - fs.Debugf(nil, "Ignoring notify for file1 or file2: %q, %v", x, e) - return - } - if e == fs.EntryDirectory { - dirChanges = append(dirChanges, x) - } else if e == fs.EntryObject { - objChanges = append(objChanges, x) - } - }, time.Second) - defer func() { close(quitChannel) }() - - var dirs []string - for _, idx := range []int{1, 3, 2} { - dir := fmt.Sprintf("dir/subdir%d", idx) - err = operations.Mkdir(remote, dir) - require.NoError(t, err) - dirs = append(dirs, dir) - } - - contents := fstest.RandomString(100) - buf := bytes.NewBufferString(contents) - - var objs []fs.Object - for _, idx := range []int{2, 4, 3} { - obji := object.NewStaticObjectInfo(fmt.Sprintf("dir/file%d", idx), time.Now(), int64(buf.Len()), true, nil, nil) - o, err := remote.Put(buf, obji) - require.NoError(t, err) - objs = append(objs, o) - } - - time.Sleep(3 * time.Second) - - assert.Equal(t, []string{"dir/subdir1", "dir/subdir3", "dir/subdir2"}, dirChanges) - assert.Equal(t, []string{"dir/file2", "dir/file4", "dir/file3"}, objChanges) - - // tidy up afterwards - for _, o := range objs { - assert.NoError(t, o.Remove()) - } - dirs = append(dirs, "dir") - for _, dir := range dirs { - assert.NoError(t, remote.Rmdir(dir)) - } -} - -// TestObjectString tests the Object String method -func TestObjectString(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - assert.Equal(t, file1.Path, obj.String()) - assert.Equal(t, "", NilObject.String()) -} - -// TestObjectFs tests the object can be found -func TestObjectFs(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - testRemote := remote - if obj.Fs() != testRemote { - // Check to see if this wraps something else - if doUnWrap := testRemote.Features().UnWrap; doUnWrap != nil { - testRemote = doUnWrap() - } - } - assert.Equal(t, obj.Fs(), testRemote) -} - -// TestObjectRemote tests the Remote is correct -func TestObjectRemote(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - assert.Equal(t, file1.Path, obj.Remote()) -} - -// TestObjectHashes checks all the hashes the object supports -func TestObjectHashes(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - file1.CheckHashes(t, obj) -} - -// TestObjectModTime tests the ModTime of the object is correct -func TestObjectModTime(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - file1.CheckModTime(t, obj, obj.ModTime(), remote.Precision()) -} - -// TestObjectMimeType tests the MimeType of the object is correct -func TestObjectMimeType(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - do, ok := obj.(fs.MimeTyper) - if !ok { - t.Skip("MimeType method not supported") - } - mimeType := do.MimeType() - if strings.ContainsRune(mimeType, ';') { - assert.Equal(t, "text/plain; charset=utf-8", mimeType) - } else { - assert.Equal(t, "text/plain", mimeType) - } -} - -// TestObjectSetModTime tests that SetModTime works -func TestObjectSetModTime(t *testing.T) { - skipIfNotOk(t) - newModTime := fstest.Time("2011-12-13T14:15:16.999999999Z") - obj := findObject(t, file1.Path) - err := obj.SetModTime(newModTime) - if err == fs.ErrorCantSetModTime || err == fs.ErrorCantSetModTimeWithoutDelete { - t.Log(err) - return - } - require.NoError(t, err) - file1.ModTime = newModTime - file1.CheckModTime(t, obj, obj.ModTime(), remote.Precision()) - // And make a new object and read it from there too - TestObjectModTime(t) -} - -// TestObjectSize tests that Size works -func TestObjectSize(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - assert.Equal(t, file1.Size, obj.Size()) -} - // read the contents of an object as a string func readObject(t *testing.T, obj fs.Object, limit int64, options ...fs.OpenOption) string { what := fmt.Sprintf("readObject(%q) limit=%d, options=%+v", obj, limit, options) @@ -850,242 +140,965 @@ func readObject(t *testing.T, obj fs.Object, limit int64, options ...fs.OpenOpti return string(contents) } -// TestObjectOpen tests that Open works -func TestObjectOpen(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - assert.Equal(t, file1Contents, readObject(t, obj, -1), "contents of file1 differ") +// ExtraConfigItem describes a config item for the tests +type ExtraConfigItem struct{ Name, Key, Value string } + +// Opt is options for Run +type Opt struct { + RemoteName string + NilObject fs.Object + ExtraConfig []ExtraConfigItem + // SkipBadWindowsCharacters skips unusable characters for windows if set + SkipBadWindowsCharacters bool } -// TestObjectOpenSeek tests that Open works with SeekOption -func TestObjectOpenSeek(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - assert.Equal(t, file1Contents[50:], readObject(t, obj, -1, &fs.SeekOption{Offset: 50}), "contents of file1 differ after seek") -} - -// TestObjectOpenRange tests that Open works with RangeOption -func TestObjectOpenRange(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - for _, test := range []struct { - ro fs.RangeOption - wantStart, wantEnd int - }{ - {fs.RangeOption{Start: 5, End: 15}, 5, 16}, - {fs.RangeOption{Start: 80, End: -1}, 80, 100}, - {fs.RangeOption{Start: 81, End: 100000}, 81, 100}, - {fs.RangeOption{Start: -1, End: 20}, 80, 100}, // if start is omitted this means get the final bytes - // {fs.RangeOption{Start: -1, End: -1}, 0, 100}, - this seems to work but the RFC doesn't define it - } { - got := readObject(t, obj, -1, &test.ro) - foundAt := strings.Index(file1Contents, got) - help := fmt.Sprintf("%#v failed want [%d:%d] got [%d:%d]", test.ro, test.wantStart, test.wantEnd, foundAt, foundAt+len(got)) - assert.Equal(t, file1Contents[test.wantStart:test.wantEnd], got, help) - } -} - -// TestObjectPartialRead tests that reading only part of the object does the correct thing -func TestObjectPartialRead(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - assert.Equal(t, file1Contents[:50], readObject(t, obj, 50), "contents of file1 differ after limited read") -} - -// TestObjectUpdate tests that Update works -func TestObjectUpdate(t *testing.T) { - skipIfNotOk(t) - contents := fstest.RandomString(200) - buf := bytes.NewBufferString(contents) - hash := hash.NewMultiHasher() - in := io.TeeReader(buf, hash) - - file1.Size = int64(buf.Len()) - obj := findObject(t, file1.Path) - obji := object.NewStaticObjectInfo(file1.Path, file1.ModTime, int64(len(contents)), true, nil, obj.Fs()) - err := obj.Update(in, obji) - require.NoError(t, err) - file1.Hashes = hash.Sums() - - // check the object has been updated - file1.Check(t, obj, remote.Precision()) - - // Re-read the object and check again - obj = findObject(t, file1.Path) - file1.Check(t, obj, remote.Precision()) - - // check contents correct - assert.Equal(t, contents, readObject(t, obj, -1), "contents of updated file1 differ") - file1Contents = contents -} - -// TestObjectStorable tests that Storable works -func TestObjectStorable(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - require.NotNil(t, !obj.Storable(), "Expecting object to be storable") -} - -// TestFsIsFile tests that an error is returned along with a valid fs -// which points to the parent directory. -func TestFsIsFile(t *testing.T) { - skipIfNotOk(t) - remoteName := subRemoteName + "/" + file2.Path - file2Copy := file2 - file2Copy.Path = "z.txt" - file2Copy.WinPath = "" - fileRemote, err := fs.NewFs(remoteName) - assert.Equal(t, fs.ErrorIsFile, err) - fstest.CheckListing(t, fileRemote, []fstest.Item{file2Copy}) -} - -// TestFsIsFileNotFound tests that an error is not returned if no object is found -func TestFsIsFileNotFound(t *testing.T) { - skipIfNotOk(t) - remoteName := subRemoteName + "/not found.txt" - fileRemote, err := fs.NewFs(remoteName) - require.NoError(t, err) - fstest.CheckListing(t, fileRemote, []fstest.Item{}) -} - -// TestPublicLink tests creation of sharable, public links -func TestPublicLink(t *testing.T) { - skipIfNotOk(t) - - doPublicLink := remote.Features().PublicLink - if doPublicLink == nil { - t.Skip("FS has no PublicLinker interface") - } - - // if object not found - link, err := doPublicLink(file1.Path + "_does_not_exist") - require.Error(t, err, "Expected to get error when file doesn't exist") - require.Equal(t, "", link, "Expected link to be empty on error") - - // sharing file for the first time - link1, err := doPublicLink(file1.Path) - require.NoError(t, err) - require.NotEqual(t, "", link1, "Link should not be empty") - - link2, err := doPublicLink(file2.Path) - require.NoError(t, err) - require.NotEqual(t, "", link2, "Link should not be empty") - - require.NotEqual(t, link1, link2, "Links to different files should differ") - - // sharing file for the 2nd time - link1, err = doPublicLink(file1.Path) - require.NoError(t, err) - require.NotEqual(t, "", link1, "Link should not be empty") - - // sharing directory for the first time - path := path.Dir(file2.Path) - link3, err := doPublicLink(path) - require.NoError(t, err) - require.NotEqual(t, "", link3, "Link should not be empty") - - // sharing directory for the second time - link3, err = doPublicLink(path) - require.NoError(t, err) - require.NotEqual(t, "", link3, "Link should not be empty") - - // sharing the "root" directory in a subremote - subRemote, _, removeSubRemote, err := fstest.RandomRemote(RemoteName, false) - require.NoError(t, err) - defer removeSubRemote() - // ensure sub remote isn't empty - buf := bytes.NewBufferString("somecontent") - obji := object.NewStaticObjectInfo("somefile", time.Now(), int64(buf.Len()), true, nil, nil) - _, err = subRemote.Put(buf, obji) - require.NoError(t, err) - - link4, err := subRemote.Features().PublicLink("") - require.NoError(t, err, "Sharing root in a sub-remote should work") - require.NotEqual(t, "", link4, "Link should not be empty") -} - -// TestObjectRemove tests Remove -func TestObjectRemove(t *testing.T) { - skipIfNotOk(t) - obj := findObject(t, file1.Path) - err := obj.Remove() - require.NoError(t, err) - // check listing without modtime as TestPublicLink may change the modtime - fstest.CheckListingWithPrecision(t, remote, []fstest.Item{file2}, nil, fs.ModTimeNotSupported) -} - -// TestFsPutStream tests uploading files when size is not known in advance -func TestFsPutStream(t *testing.T) { - skipIfNotOk(t) - if remote.Features().PutStream == nil { - t.Skip("FS has no PutStream interface") - } - - file := fstest.Item{ - ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"), - Path: "piped data.txt", - Size: -1, // use unknown size during upload - } - - tries := 1 - const maxTries = 10 -again: - contentSize := 100 - contents := fstest.RandomString(contentSize) - buf := bytes.NewBufferString(contents) - hash := hash.NewMultiHasher() - in := io.TeeReader(buf, hash) - - file.Size = -1 - obji := object.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil) - obj, err := remote.Features().PutStream(in, obji) - if err != nil { - // Retry if err returned a retry error - if fserrors.IsRetryError(err) && tries < maxTries { - t.Logf("Put error: %v - low level retry %d/%d", err, tries, maxTries) - time.Sleep(2 * time.Second) - - tries++ - goto again +// Run runs the basic integration tests for a remote using the remote +// name passed in and the nil object +func Run(t *testing.T, opt *Opt) { + var ( + remote fs.Fs + remoteName = opt.RemoteName + subRemoteName string + subRemoteLeaf string + file1 = fstest.Item{ + ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"), + Path: "file name.txt", } - require.NoError(t, err, fmt.Sprintf("PutStream Unknown Length error: %v", err)) - } - file.Hashes = hash.Sums() - file.Size = int64(contentSize) // use correct size when checking - file.Check(t, obj, remote.Precision()) - // Re-read the object and check again - obj = findObject(t, file.Path) - file.Check(t, obj, remote.Precision()) -} + file1Contents string + file2 = fstest.Item{ + ModTime: fstest.Time("2001-02-03T04:05:10.123123123Z"), + Path: `hello? sausage/êé/Hello, 世界/ " ' @ < > & ? + ≠/z.txt`, + WinPath: `hello_ sausage/êé/Hello, 世界/ _ ' @ _ _ & _ + ≠/z.txt`, + } + isLocalRemote bool + ) -// TestObjectPurge tests Purge -func TestObjectPurge(t *testing.T) { - skipIfNotOk(t) - - err := operations.Purge(remote, "") - require.NoError(t, err) - fstest.CheckListing(t, remote, []fstest.Item{}) - - err = operations.Purge(remote, "") - assert.Error(t, err, "Expecting error after on second purge") -} - -// TestInternal calls InternalTest() on the Fs -func TestInternal(t *testing.T) { - skipIfNotOk(t) - if it, ok := remote.(InternalTester); ok { - it.InternalTest(t) - } else { - t.Skipf("%T does not implement InternalTester", remote) - } -} - -// TestFinalise tidies up after the previous tests -func TestFinalise(t *testing.T) { - skipIfNotOk(t) - if strings.HasPrefix(RemoteName, "/") { - // Remove temp directory - err := os.Remove(RemoteName) + // Make the Fs we are testing with, initialising the global variables + // subRemoteName - name of the remote after the TestRemote: + // subRemoteLeaf - a subdirectory to use under that + // remote - the result of fs.NewFs(TestRemote:subRemoteName) + newFs := func(t *testing.T) { + var err error + subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(remoteName) require.NoError(t, err) + remote, err = fs.NewFs(subRemoteName) + if err == fs.ErrorNotFoundInConfigFile { + t.Logf("Didn't find %q in config file - skipping tests", remoteName) + return + } + require.NoError(t, err, fmt.Sprintf("unexpected error: %v", err)) } + + // Skip the test if the remote isn't configured + skipIfNotOk := func(t *testing.T) { + if remote == nil { + t.Skipf("WARN: %q not configured", remoteName) + } + } + + // Skip if remote is not ListR capable, otherwise set the useListR + // flag, returning a function to restore its value + skipIfNotListR := func(t *testing.T) func() { + skipIfNotOk(t) + if remote.Features().ListR == nil { + t.Skip("FS has no ListR interface") + } + previous := fs.Config.UseListR + fs.Config.UseListR = true + return func() { + fs.Config.UseListR = previous + } + } + + // TestInit tests basic intitialisation + t.Run("TestInit", func(t *testing.T) { + var err error + + // Remove bad characters from Windows file name if set + if opt.SkipBadWindowsCharacters { + t.Logf("Removing bad windows characters from test file") + file2.Path = winPath(file2.Path) + } + + fstest.Initialise() + + // Set extra config if supplied + for _, item := range opt.ExtraConfig { + config.FileSet(item.Name, item.Key, item.Value) + } + if *fstest.RemoteName != "" { + remoteName = *fstest.RemoteName + } + t.Logf("Using remote %q", remoteName) + if remoteName == "" { + remoteName, err = fstest.LocalRemote() + require.NoError(t, err) + isLocalRemote = true + } + + newFs(t) + + skipIfNotOk(t) + + err = remote.Mkdir("") + require.NoError(t, err) + fstest.CheckListing(t, remote, []fstest.Item{}) + }) + + // TestFsString tests the String method + t.Run("TestFsString", func(t *testing.T) { + skipIfNotOk(t) + str := remote.String() + require.NotEqual(t, "", str) + }) + + // TestFsName tests the Name method + t.Run("TestFsName", func(t *testing.T) { + skipIfNotOk(t) + got := remote.Name() + want := remoteName + if isLocalRemote { + want = "local:" + } + require.Equal(t, want, got+":") + }) + + // TestFsRoot tests the Root method + t.Run("TestFsRoot", func(t *testing.T) { + skipIfNotOk(t) + name := remote.Name() + ":" + root := remote.Root() + if isLocalRemote { + // only check last path element on local + require.Equal(t, filepath.Base(subRemoteName), filepath.Base(root)) + } else { + require.Equal(t, subRemoteName, name+root) + } + }) + + // TestFsRmdirEmpty tests deleting an empty directory + t.Run("TestFsRmdirEmpty", func(t *testing.T) { + skipIfNotOk(t) + err := remote.Rmdir("") + require.NoError(t, err) + }) + + // TestFsRmdirNotFound tests deleting a non existent directory + t.Run("TestFsRmdirNotFound", func(t *testing.T) { + skipIfNotOk(t) + err := remote.Rmdir("") + assert.Error(t, err, "Expecting error on Rmdir non existent") + }) + + // TestFsMkdir tests tests making a directory + t.Run("TestFsMkdir", func(t *testing.T) { + skipIfNotOk(t) + + // Use a new directory here. This is for the container based + // remotes which take time to create and destroy a container + // (eg azure blob) + newFs(t) + + err := remote.Mkdir("") + require.NoError(t, err) + fstest.CheckListing(t, remote, []fstest.Item{}) + + err = remote.Mkdir("") + require.NoError(t, err) + }) + + // TestFsMkdirRmdirSubdir tests making and removing a sub directory + t.Run("TestFsMkdirRmdirSubdir", func(t *testing.T) { + skipIfNotOk(t) + dir := "dir/subdir" + err := operations.Mkdir(remote, dir) + require.NoError(t, err) + fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir", "dir/subdir"}, fs.Config.ModifyWindow) + + err = operations.Rmdir(remote, dir) + require.NoError(t, err) + fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir"}, fs.Config.ModifyWindow) + + err = operations.Rmdir(remote, "dir") + require.NoError(t, err) + fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{}, fs.Config.ModifyWindow) + }) + + // TestFsListEmpty tests listing an empty directory + t.Run("TestFsListEmpty", func(t *testing.T) { + skipIfNotOk(t) + fstest.CheckListing(t, remote, []fstest.Item{}) + }) + + // TestFsListDirEmpty tests listing the directories from an empty directory + TestFsListDirEmpty := func(t *testing.T) { + skipIfNotOk(t) + objs, dirs, err := walk.GetAll(remote, "", true, 1) + require.NoError(t, err) + assert.Equal(t, []string{}, objsToNames(objs)) + assert.Equal(t, []string{}, dirsToNames(dirs)) + } + t.Run("TestFsListDirEmpty", TestFsListDirEmpty) + + // TestFsListRDirEmpty tests listing the directories from an empty directory using ListR + t.Run("TestFsListRDirEmpty", func(t *testing.T) { + defer skipIfNotListR(t)() + TestFsListDirEmpty(t) + }) + + // TestFsNewObjectNotFound tests not finding a object + t.Run("TestFsNewObjectNotFound", func(t *testing.T) { + skipIfNotOk(t) + // Object in an existing directory + o, err := remote.NewObject("potato") + assert.Nil(t, o) + assert.Equal(t, fs.ErrorObjectNotFound, err) + // Now try an object in a non existing directory + o, err = remote.NewObject("directory/not/found/potato") + assert.Nil(t, o) + assert.Equal(t, fs.ErrorObjectNotFound, err) + }) + + // TestFsPutFile1 tests putting a file + t.Run("TestFsPutFile1", func(t *testing.T) { + skipIfNotOk(t) + file1Contents = testPut(t, remote, &file1) + }) + + // TestFsPutError tests uploading a file where there is an error + // + // It makes sure that aborting a file half way through does not create + // a file on the remote. + t.Run("TestFsPutError", func(t *testing.T) { + skipIfNotOk(t) + + // Read 50 bytes then produce an error + contents := fstest.RandomString(50) + buf := bytes.NewBufferString(contents) + er := &errorReader{errors.New("potato")} + in := io.MultiReader(buf, er) + + obji := object.NewStaticObjectInfo(file2.Path, file2.ModTime, 100, true, nil, nil) + _, err := remote.Put(in, obji) + // assert.Nil(t, obj) - FIXME some remotes return the object even on nil + assert.NotNil(t, err) + + obj, err := remote.NewObject(file2.Path) + assert.Nil(t, obj) + assert.Equal(t, fs.ErrorObjectNotFound, err) + }) + + // TestFsPutFile2 tests putting a file into a subdirectory + t.Run("TestFsPutFile2", func(t *testing.T) { + skipIfNotOk(t) + /* file2Contents = */ testPut(t, remote, &file2) + }) + + // TestFsUpdateFile1 tests updating file1 with new contents + t.Run("TestFsUpdateFile1", func(t *testing.T) { + skipIfNotOk(t) + file1Contents = testPut(t, remote, &file1) + // Note that the next test will check there are no duplicated file names + }) + + // TestFsListDirFile2 tests the files are correctly uploaded by doing + // Depth 1 directory listings + TestFsListDirFile2 := func(t *testing.T) { + skipIfNotOk(t) + list := func(dir string, expectedDirNames, expectedObjNames []string) { + var objNames, dirNames []string + for i := 1; i <= *fstest.ListRetries; i++ { + objs, dirs, err := walk.GetAll(remote, dir, true, 1) + if errors.Cause(err) == fs.ErrorDirNotFound { + objs, dirs, err = walk.GetAll(remote, winPath(dir), true, 1) + } + require.NoError(t, err) + objNames = objsToNames(objs) + dirNames = dirsToNames(dirs) + if len(objNames) >= len(expectedObjNames) && len(dirNames) >= len(expectedDirNames) { + break + } + t.Logf("Sleeping for 1 second for TestFsListDirFile2 eventual consistency: %d/%d", i, *fstest.ListRetries) + time.Sleep(1 * time.Second) + } + assert.Equal(t, expectedDirNames, dirNames) + assert.Equal(t, expectedObjNames, objNames) + } + dir := file2.Path + deepest := true + for dir != "" { + expectedObjNames := []string{} + expectedDirNames := []string{} + child := dir + dir = path.Dir(dir) + if dir == "." { + dir = "" + expectedObjNames = append(expectedObjNames, winPath(file1.Path)) + } + if deepest { + expectedObjNames = append(expectedObjNames, winPath(file2.Path)) + deepest = false + } else { + expectedDirNames = append(expectedDirNames, winPath(child)) + } + list(dir, expectedDirNames, expectedObjNames) + } + } + t.Run("TestFsListDirFile2", TestFsListDirFile2) + + // TestFsListRDirFile2 tests the files are correctly uploaded by doing + // Depth 1 directory listings using ListR + t.Run("TestFsListRDirFile2", func(t *testing.T) { + defer skipIfNotListR(t)() + TestFsListDirFile2(t) + }) + + // TestFsListDirRoot tests that DirList works in the root + TestFsListDirRoot := func(t *testing.T) { + skipIfNotOk(t) + rootRemote, err := fs.NewFs(remoteName) + require.NoError(t, err) + _, dirs, err := walk.GetAll(rootRemote, "", true, 1) + require.NoError(t, err) + assert.Contains(t, dirsToNames(dirs), subRemoteLeaf, "Remote leaf not found") + } + t.Run("TestFsListDirRoot", TestFsListDirRoot) + + // TestFsListRDirRoot tests that DirList works in the root using ListR + t.Run("TestFsListRDirRoot", func(t *testing.T) { + defer skipIfNotListR(t)() + TestFsListDirRoot(t) + }) + + // TestFsListSubdir tests List works for a subdirectory + TestFsListSubdir := func(t *testing.T) { + skipIfNotOk(t) + fileName := file2.Path + var err error + var objs []fs.Object + var dirs []fs.Directory + for i := 0; i < 2; i++ { + dir, _ := path.Split(fileName) + dir = dir[:len(dir)-1] + objs, dirs, err = walk.GetAll(remote, dir, true, -1) + if err != fs.ErrorDirNotFound { + break + } + fileName = file2.WinPath + } + require.NoError(t, err) + require.Len(t, objs, 1) + assert.Equal(t, fileName, objs[0].Remote()) + require.Len(t, dirs, 0) + } + t.Run("TestFsListSubdir", TestFsListSubdir) + + // TestFsListRSubdir tests List works for a subdirectory using ListR + t.Run("TestFsListRSubdir", func(t *testing.T) { + defer skipIfNotListR(t)() + TestFsListSubdir(t) + }) + + // TestFsListLevel2 tests List works for 2 levels + TestFsListLevel2 := func(t *testing.T) { + skipIfNotOk(t) + objs, dirs, err := walk.GetAll(remote, "", true, 2) + if err == fs.ErrorLevelNotSupported { + return + } + require.NoError(t, err) + assert.Equal(t, []string{file1.Path}, objsToNames(objs)) + assert.Equal(t, []string{`hello_ sausage`, `hello_ sausage/êé`}, dirsToNames(dirs)) + } + t.Run("TestFsListLevel2", TestFsListLevel2) + + // TestFsListRLevel2 tests List works for 2 levels using ListR + t.Run("TestFsListRLevel2", func(t *testing.T) { + defer skipIfNotListR(t)() + TestFsListLevel2(t) + }) + + // TestFsListFile1 tests file present + t.Run("TestFsListFile1", func(t *testing.T) { + skipIfNotOk(t) + fstest.CheckListing(t, remote, []fstest.Item{file1, file2}) + }) + + // TestFsNewObject tests NewObject + t.Run("TestFsNewObject", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + file1.Check(t, obj, remote.Precision()) + }) + + // TestFsListFile1and2 tests two files present + t.Run("TestFsListFile1and2", func(t *testing.T) { + skipIfNotOk(t) + fstest.CheckListing(t, remote, []fstest.Item{file1, file2}) + }) + + // TestFsNewObjectDir tests NewObject on a directory which should produce an error + t.Run("TestFsNewObjectDir", func(t *testing.T) { + skipIfNotOk(t) + dir := path.Dir(file2.Path) + obj, err := remote.NewObject(dir) + assert.Nil(t, obj) + assert.NotNil(t, err) + }) + + // TestFsCopy tests Copy + t.Run("TestFsCopy", func(t *testing.T) { + skipIfNotOk(t) + + // Check have Copy + doCopy := remote.Features().Copy + if doCopy == nil { + t.Skip("FS has no Copier interface") + } + + // Test with file2 so have + and ' ' in file name + var file2Copy = file2 + file2Copy.Path += "-copy" + + // do the copy + src := findObject(t, remote, file2.Path) + dst, err := doCopy(src, file2Copy.Path) + if err == fs.ErrorCantCopy { + t.Skip("FS can't copy") + } + require.NoError(t, err, fmt.Sprintf("Error: %#v", err)) + + // check file exists in new listing + fstest.CheckListing(t, remote, []fstest.Item{file1, file2, file2Copy}) + + // Check dst lightly - list above has checked ModTime/Hashes + assert.Equal(t, file2Copy.Path, dst.Remote()) + + // Delete copy + err = dst.Remove() + require.NoError(t, err) + + }) + + // TestFsMove tests Move + t.Run("TestFsMove", func(t *testing.T) { + skipIfNotOk(t) + + // Check have Move + doMove := remote.Features().Move + if doMove == nil { + t.Skip("FS has no Mover interface") + } + + // state of files now: + // 1: file name.txt + // 2: hello sausage?/../z.txt + + var file1Move = file1 + var file2Move = file2 + + // check happy path, i.e. no naming conflicts when rename and move are two + // separate operations + file2Move.Path = "other.txt" + file2Move.WinPath = "" + src := findObject(t, remote, file2.Path) + dst, err := doMove(src, file2Move.Path) + if err == fs.ErrorCantMove { + t.Skip("FS can't move") + } + require.NoError(t, err) + // check file exists in new listing + fstest.CheckListing(t, remote, []fstest.Item{file1, file2Move}) + // Check dst lightly - list above has checked ModTime/Hashes + assert.Equal(t, file2Move.Path, dst.Remote()) + // 1: file name.txt + // 2: other.txt + + // Check conflict on "rename, then move" + file1Move.Path = "moveTest/other.txt" + src = findObject(t, remote, file1.Path) + _, err = doMove(src, file1Move.Path) + require.NoError(t, err) + fstest.CheckListing(t, remote, []fstest.Item{file1Move, file2Move}) + // 1: moveTest/other.txt + // 2: other.txt + + // Check conflict on "move, then rename" + src = findObject(t, remote, file1Move.Path) + _, err = doMove(src, file1.Path) + require.NoError(t, err) + fstest.CheckListing(t, remote, []fstest.Item{file1, file2Move}) + // 1: file name.txt + // 2: other.txt + + src = findObject(t, remote, file2Move.Path) + _, err = doMove(src, file2.Path) + require.NoError(t, err) + fstest.CheckListing(t, remote, []fstest.Item{file1, file2}) + // 1: file name.txt + // 2: hello sausage?/../z.txt + }) + + // Move src to this remote using server side move operations. + // + // Will only be called if src.Fs().Name() == f.Name() + // + // If it isn't possible then return fs.ErrorCantDirMove + // + // If destination exists then return fs.ErrorDirExists + + // TestFsDirMove tests DirMove + // + // go test -v -run '^Test(Setup|Init|FsMkdir|FsPutFile1|FsPutFile2|FsUpdateFile1|FsDirMove)$ + t.Run("TestFsDirMove", func(t *testing.T) { + skipIfNotOk(t) + + // Check have DirMove + doDirMove := remote.Features().DirMove + if doDirMove == nil { + t.Skip("FS has no DirMover interface") + } + + // Check it can't move onto itself + err := doDirMove(remote, "", "") + require.Equal(t, fs.ErrorDirExists, err) + + // new remote + newRemote, _, removeNewRemote, err := fstest.RandomRemote(remoteName, false) + require.NoError(t, err) + defer removeNewRemote() + + const newName = "new_name/sub_new_name" + // try the move + err = newRemote.Features().DirMove(remote, "", newName) + require.NoError(t, err) + + // check remotes + // FIXME: Prints errors. + fstest.CheckListing(t, remote, []fstest.Item{}) + file1Copy := file1 + file1Copy.Path = path.Join(newName, file1.Path) + file2Copy := file2 + file2Copy.Path = path.Join(newName, file2.Path) + file2Copy.WinPath = path.Join(newName, file2.WinPath) + fstest.CheckListing(t, newRemote, []fstest.Item{file2Copy, file1Copy}) + + // move it back + err = doDirMove(newRemote, newName, "") + require.NoError(t, err) + + // check remotes + fstest.CheckListing(t, remote, []fstest.Item{file2, file1}) + fstest.CheckListing(t, newRemote, []fstest.Item{}) + }) + + // TestFsRmdirFull tests removing a non empty directory + t.Run("TestFsRmdirFull", func(t *testing.T) { + skipIfNotOk(t) + err := remote.Rmdir("") + require.Error(t, err, "Expecting error on RMdir on non empty remote") + }) + + // TestFsPrecision tests the Precision of the Fs + t.Run("TestFsPrecision", func(t *testing.T) { + skipIfNotOk(t) + precision := remote.Precision() + if precision == fs.ModTimeNotSupported { + return + } + if precision > time.Second || precision < 0 { + t.Fatalf("Precision out of range %v", precision) + } + // FIXME check expected precision + }) + + // TestFsChangeNotify tests that changes are properly + // propagated + // + // go test -v -remote TestDrive: -run '^Test(Setup|Init|FsChangeNotify)$' -verbose + t.Run("TestFsChangeNotify", func(t *testing.T) { + skipIfNotOk(t) + + // Check have ChangeNotify + doChangeNotify := remote.Features().ChangeNotify + if doChangeNotify == nil { + t.Skip("FS has no ChangeNotify interface") + } + + err := operations.Mkdir(remote, "dir") + require.NoError(t, err) + + dirChanges := []string{} + objChanges := []string{} + quitChannel := doChangeNotify(func(x string, e fs.EntryType) { + fs.Debugf(nil, "doChangeNotify(%q, %+v)", x, e) + if strings.HasPrefix(x, file1.Path[:5]) || strings.HasPrefix(x, file2.Path[:5]) { + fs.Debugf(nil, "Ignoring notify for file1 or file2: %q, %v", x, e) + return + } + if e == fs.EntryDirectory { + dirChanges = append(dirChanges, x) + } else if e == fs.EntryObject { + objChanges = append(objChanges, x) + } + }, time.Second) + defer func() { close(quitChannel) }() + + var dirs []string + for _, idx := range []int{1, 3, 2} { + dir := fmt.Sprintf("dir/subdir%d", idx) + err = operations.Mkdir(remote, dir) + require.NoError(t, err) + dirs = append(dirs, dir) + } + + contents := fstest.RandomString(100) + buf := bytes.NewBufferString(contents) + + var objs []fs.Object + for _, idx := range []int{2, 4, 3} { + obji := object.NewStaticObjectInfo(fmt.Sprintf("dir/file%d", idx), time.Now(), int64(buf.Len()), true, nil, nil) + o, err := remote.Put(buf, obji) + require.NoError(t, err) + objs = append(objs, o) + } + + time.Sleep(3 * time.Second) + + assert.Equal(t, []string{"dir/subdir1", "dir/subdir3", "dir/subdir2"}, dirChanges) + assert.Equal(t, []string{"dir/file2", "dir/file4", "dir/file3"}, objChanges) + + // tidy up afterwards + for _, o := range objs { + assert.NoError(t, o.Remove()) + } + dirs = append(dirs, "dir") + for _, dir := range dirs { + assert.NoError(t, remote.Rmdir(dir)) + } + }) + + // TestObjectString tests the Object String method + t.Run("TestObjectString", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + assert.Equal(t, file1.Path, obj.String()) + assert.Equal(t, "", opt.NilObject.String()) + }) + + // TestObjectFs tests the object can be found + t.Run("TestObjectFs", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + testRemote := remote + if obj.Fs() != testRemote { + // Check to see if this wraps something else + if doUnWrap := testRemote.Features().UnWrap; doUnWrap != nil { + testRemote = doUnWrap() + } + } + assert.Equal(t, obj.Fs(), testRemote) + }) + + // TestObjectRemote tests the Remote is correct + t.Run("TestObjectRemote", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + assert.Equal(t, file1.Path, obj.Remote()) + }) + + // TestObjectHashes checks all the hashes the object supports + t.Run("TestObjectHashes", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + file1.CheckHashes(t, obj) + }) + + // TestObjectModTime tests the ModTime of the object is correct + TestObjectModTime := func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + file1.CheckModTime(t, obj, obj.ModTime(), remote.Precision()) + } + t.Run("TestObjectModTime", TestObjectModTime) + + // TestObjectMimeType tests the MimeType of the object is correct + t.Run("TestObjectMimeType", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + do, ok := obj.(fs.MimeTyper) + if !ok { + t.Skip("MimeType method not supported") + } + mimeType := do.MimeType() + if strings.ContainsRune(mimeType, ';') { + assert.Equal(t, "text/plain; charset=utf-8", mimeType) + } else { + assert.Equal(t, "text/plain", mimeType) + } + }) + + // TestObjectSetModTime tests that SetModTime works + t.Run("TestObjectSetModTime", func(t *testing.T) { + skipIfNotOk(t) + newModTime := fstest.Time("2011-12-13T14:15:16.999999999Z") + obj := findObject(t, remote, file1.Path) + err := obj.SetModTime(newModTime) + if err == fs.ErrorCantSetModTime || err == fs.ErrorCantSetModTimeWithoutDelete { + t.Log(err) + return + } + require.NoError(t, err) + file1.ModTime = newModTime + file1.CheckModTime(t, obj, obj.ModTime(), remote.Precision()) + // And make a new object and read it from there too + TestObjectModTime(t) + }) + + // TestObjectSize tests that Size works + t.Run("TestObjectSize", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + assert.Equal(t, file1.Size, obj.Size()) + }) + + // TestObjectOpen tests that Open works + t.Run("TestObjectOpen", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + assert.Equal(t, file1Contents, readObject(t, obj, -1), "contents of file1 differ") + }) + + // TestObjectOpenSeek tests that Open works with SeekOption + t.Run("TestObjectOpenSeek", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + assert.Equal(t, file1Contents[50:], readObject(t, obj, -1, &fs.SeekOption{Offset: 50}), "contents of file1 differ after seek") + }) + + // TestObjectOpenRange tests that Open works with RangeOption + t.Run("TestObjectOpenRange", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + for _, test := range []struct { + ro fs.RangeOption + wantStart, wantEnd int + }{ + {fs.RangeOption{Start: 5, End: 15}, 5, 16}, + {fs.RangeOption{Start: 80, End: -1}, 80, 100}, + {fs.RangeOption{Start: 81, End: 100000}, 81, 100}, + {fs.RangeOption{Start: -1, End: 20}, 80, 100}, // if start is omitted this means get the final bytes + // {fs.RangeOption{Start: -1, End: -1}, 0, 100}, - this seems to work but the RFC doesn't define it + } { + got := readObject(t, obj, -1, &test.ro) + foundAt := strings.Index(file1Contents, got) + help := fmt.Sprintf("%#v failed want [%d:%d] got [%d:%d]", test.ro, test.wantStart, test.wantEnd, foundAt, foundAt+len(got)) + assert.Equal(t, file1Contents[test.wantStart:test.wantEnd], got, help) + } + }) + + // TestObjectPartialRead tests that reading only part of the object does the correct thing + t.Run("TestObjectPartialRead", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + assert.Equal(t, file1Contents[:50], readObject(t, obj, 50), "contents of file1 differ after limited read") + }) + + // TestObjectUpdate tests that Update works + t.Run("TestObjectUpdate", func(t *testing.T) { + skipIfNotOk(t) + contents := fstest.RandomString(200) + buf := bytes.NewBufferString(contents) + hash := hash.NewMultiHasher() + in := io.TeeReader(buf, hash) + + file1.Size = int64(buf.Len()) + obj := findObject(t, remote, file1.Path) + obji := object.NewStaticObjectInfo(file1.Path, file1.ModTime, int64(len(contents)), true, nil, obj.Fs()) + err := obj.Update(in, obji) + require.NoError(t, err) + file1.Hashes = hash.Sums() + + // check the object has been updated + file1.Check(t, obj, remote.Precision()) + + // Re-read the object and check again + obj = findObject(t, remote, file1.Path) + file1.Check(t, obj, remote.Precision()) + + // check contents correct + assert.Equal(t, contents, readObject(t, obj, -1), "contents of updated file1 differ") + file1Contents = contents + }) + + // TestObjectStorable tests that Storable works + t.Run("TestObjectStorable", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + require.NotNil(t, !obj.Storable(), "Expecting object to be storable") + }) + + // TestFsIsFile tests that an error is returned along with a valid fs + // which points to the parent directory. + t.Run("TestFsIsFile", func(t *testing.T) { + skipIfNotOk(t) + remoteName := subRemoteName + "/" + file2.Path + file2Copy := file2 + file2Copy.Path = "z.txt" + file2Copy.WinPath = "" + fileRemote, err := fs.NewFs(remoteName) + assert.Equal(t, fs.ErrorIsFile, err) + fstest.CheckListing(t, fileRemote, []fstest.Item{file2Copy}) + }) + + // TestFsIsFileNotFound tests that an error is not returned if no object is found + t.Run("TestFsIsFileNotFound", func(t *testing.T) { + skipIfNotOk(t) + remoteName := subRemoteName + "/not found.txt" + fileRemote, err := fs.NewFs(remoteName) + require.NoError(t, err) + fstest.CheckListing(t, fileRemote, []fstest.Item{}) + }) + + // TestPublicLink tests creation of sharable, public links + t.Run("TestPublicLink", func(t *testing.T) { + skipIfNotOk(t) + + doPublicLink := remote.Features().PublicLink + if doPublicLink == nil { + t.Skip("FS has no PublicLinker interface") + } + + // if object not found + link, err := doPublicLink(file1.Path + "_does_not_exist") + require.Error(t, err, "Expected to get error when file doesn't exist") + require.Equal(t, "", link, "Expected link to be empty on error") + + // sharing file for the first time + link1, err := doPublicLink(file1.Path) + require.NoError(t, err) + require.NotEqual(t, "", link1, "Link should not be empty") + + link2, err := doPublicLink(file2.Path) + require.NoError(t, err) + require.NotEqual(t, "", link2, "Link should not be empty") + + require.NotEqual(t, link1, link2, "Links to different files should differ") + + // sharing file for the 2nd time + link1, err = doPublicLink(file1.Path) + require.NoError(t, err) + require.NotEqual(t, "", link1, "Link should not be empty") + + // sharing directory for the first time + path := path.Dir(file2.Path) + link3, err := doPublicLink(path) + require.NoError(t, err) + require.NotEqual(t, "", link3, "Link should not be empty") + + // sharing directory for the second time + link3, err = doPublicLink(path) + require.NoError(t, err) + require.NotEqual(t, "", link3, "Link should not be empty") + + // sharing the "root" directory in a subremote + subRemote, _, removeSubRemote, err := fstest.RandomRemote(remoteName, false) + require.NoError(t, err) + defer removeSubRemote() + // ensure sub remote isn't empty + buf := bytes.NewBufferString("somecontent") + obji := object.NewStaticObjectInfo("somefile", time.Now(), int64(buf.Len()), true, nil, nil) + _, err = subRemote.Put(buf, obji) + require.NoError(t, err) + + link4, err := subRemote.Features().PublicLink("") + require.NoError(t, err, "Sharing root in a sub-remote should work") + require.NotEqual(t, "", link4, "Link should not be empty") + }) + + // TestObjectRemove tests Remove + t.Run("TestObjectRemove", func(t *testing.T) { + skipIfNotOk(t) + obj := findObject(t, remote, file1.Path) + err := obj.Remove() + require.NoError(t, err) + // check listing without modtime as TestPublicLink may change the modtime + fstest.CheckListingWithPrecision(t, remote, []fstest.Item{file2}, nil, fs.ModTimeNotSupported) + }) + + // TestFsPutStream tests uploading files when size is not known in advance + t.Run("TestFsPutStream", func(t *testing.T) { + skipIfNotOk(t) + if remote.Features().PutStream == nil { + t.Skip("FS has no PutStream interface") + } + + file := fstest.Item{ + ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"), + Path: "piped data.txt", + Size: -1, // use unknown size during upload + } + + tries := 1 + const maxTries = 10 + again: + contentSize := 100 + contents := fstest.RandomString(contentSize) + buf := bytes.NewBufferString(contents) + hash := hash.NewMultiHasher() + in := io.TeeReader(buf, hash) + + file.Size = -1 + obji := object.NewStaticObjectInfo(file.Path, file.ModTime, file.Size, true, nil, nil) + obj, err := remote.Features().PutStream(in, obji) + if err != nil { + // Retry if err returned a retry error + if fserrors.IsRetryError(err) && tries < maxTries { + t.Logf("Put error: %v - low level retry %d/%d", err, tries, maxTries) + time.Sleep(2 * time.Second) + + tries++ + goto again + } + require.NoError(t, err, fmt.Sprintf("PutStream Unknown Length error: %v", err)) + } + file.Hashes = hash.Sums() + file.Size = int64(contentSize) // use correct size when checking + file.Check(t, obj, remote.Precision()) + // Re-read the object and check again + obj = findObject(t, remote, file.Path) + file.Check(t, obj, remote.Precision()) + }) + + // TestObjectPurge tests Purge + t.Run("TestObjectPurge", func(t *testing.T) { + skipIfNotOk(t) + + err := operations.Purge(remote, "") + require.NoError(t, err) + fstest.CheckListing(t, remote, []fstest.Item{}) + + err = operations.Purge(remote, "") + assert.Error(t, err, "Expecting error after on second purge") + }) + + // TestInternal calls InternalTest() on the Fs + t.Run("TestInternal", func(t *testing.T) { + skipIfNotOk(t) + if it, ok := remote.(InternalTester); ok { + it.InternalTest(t) + } else { + t.Skipf("%T does not implement InternalTester", remote) + } + }) + + // TestFinalise tidies up after the previous tests + t.Run("TestFinalise", func(t *testing.T) { + skipIfNotOk(t) + if strings.HasPrefix(remoteName, "/") { + // Remove temp directory + err := os.Remove(remoteName) + require.NoError(t, err) + } + }) } diff --git a/fstest/fstests/gen_tests.go b/fstest/fstests/gen_tests.go deleted file mode 100644 index 4f4010cda..000000000 --- a/fstest/fstests/gen_tests.go +++ /dev/null @@ -1,171 +0,0 @@ -// +build ignore - -// Make the test files from fstests.go -package main - -import ( - "bufio" - "html/template" - "log" - "os" - "os/exec" - "regexp" - "strings" -) - -// Search fstests.go and return all the test function names -func findTestFunctions() []string { - fns := []string{} - matcher := regexp.MustCompile(`^func\s+(Test.*?)\(`) - - in, err := os.Open("fstests.go") - if err != nil { - log.Fatalf("Couldn't open fstests.go: %v", err) - } - defer in.Close() - - scanner := bufio.NewScanner(in) - for scanner.Scan() { - line := scanner.Text() - matches := matcher.FindStringSubmatch(line) - if len(matches) > 0 { - fns = append(fns, matches[1]) - } - } - - if err := scanner.Err(); err != nil { - log.Fatalf("Error scanning file: %v", err) - } - return fns -} - -// Data to substitute -type Data struct { - Regenerate string - FsName string - UpperFsName string - TestName string - Fns []string - Suffix string - BuildConstraint string -} - -var testProgram = ` -// Test {{ .UpperFsName }} filesystem interface -// -// Automatically generated - DO NOT EDIT -// Regenerate with: {{ .Regenerate }}{{ if ne .BuildConstraint "" }} - -// +build {{ .BuildConstraint }} -{{end}} -package {{ .FsName }}_test - -import ( - "testing" - - "github.com/ncw/rclone/backend/{{ .FsName }}" - "github.com/ncw/rclone/fs" - "github.com/ncw/rclone/fstest/fstests" -{{ if (or (eq .FsName "crypt") (eq .FsName "cache")) }} _ "github.com/ncw/rclone/backend/local" -{{end}}) - -func TestSetup{{ .Suffix }}(t *testing.T)() { - fstests.NilObject = fs.Object((*{{ .FsName }}.Object)(nil)) - fstests.RemoteName = "{{ .TestName }}" -} - -// Generic tests for the Fs -{{ range $fn := .Fns }}func {{ $fn }}{{ $.Suffix }}(t *testing.T){ fstests.{{ $fn }}(t) } -{{ end }} -` - -// options for generateTestProgram -type ( - suffix string - buildConstraint string -) - -// Generate test file piping it through gofmt -func generateTestProgram(t *template.Template, fns []string, Fsname string, options ...interface{}) { - data := Data{ - Regenerate: "make gen_tests", - FsName: strings.ToLower(Fsname), - UpperFsName: Fsname, - Fns: fns, - } - - for _, option := range options { - switch x := option.(type) { - case suffix: - data.Suffix = string(x) - case buildConstraint: - data.BuildConstraint = string(x) - default: - log.Fatalf("Unknown option type %T", option) - } - } - - data.TestName = "Test" + data.UpperFsName + data.Suffix + ":" - outfile := "../../backend/" + data.FsName + "/" + data.FsName + data.Suffix + "_test.go" - - if data.FsName == "local" { - data.TestName = "" - } - - cmd := exec.Command("gofmt") - - log.Printf("Writing %q", outfile) - out, err := os.Create(outfile) - if err != nil { - log.Fatalf("Failed to write %q: %v", outfile, err) - } - cmd.Stdout = out - - gofmt, err := cmd.StdinPipe() - if err != nil { - log.Fatalf("Failed to StdinPipe %q: %v", outfile, err) - } - if err = cmd.Start(); err != nil { - log.Fatalf("Failed to Start %q: %v", outfile, err) - } - if err = t.Execute(gofmt, data); err != nil { - log.Fatalf("Failed to Execute %q: %v", outfile, err) - } - if err = gofmt.Close(); err != nil { - log.Fatalf("Failed to Close gofmt on %q: %v", outfile, err) - } - if err = cmd.Wait(); err != nil { - log.Fatalf("Failed to Wait %q: %v", outfile, err) - } - if err = out.Close(); err != nil { - log.Fatalf("Failed to Close out %q: %v", outfile, err) - } -} - -func main() { - fns := findTestFunctions() - t := template.Must(template.New("main").Parse(testProgram)) - generateTestProgram(t, fns, "Local") - generateTestProgram(t, fns, "Swift") - generateTestProgram(t, fns, "S3") - generateTestProgram(t, fns, "Drive") - generateTestProgram(t, fns, "GoogleCloudStorage") - generateTestProgram(t, fns, "Dropbox") - generateTestProgram(t, fns, "AmazonCloudDrive", buildConstraint("acd")) - generateTestProgram(t, fns, "OneDrive") - generateTestProgram(t, fns, "Hubic") - generateTestProgram(t, fns, "B2") - generateTestProgram(t, fns, "Yandex") - generateTestProgram(t, fns, "Crypt") - generateTestProgram(t, fns, "Crypt", suffix("2")) - generateTestProgram(t, fns, "Crypt", suffix("3")) - generateTestProgram(t, fns, "Sftp", buildConstraint("!plan9,go1.8")) - generateTestProgram(t, fns, "FTP") - generateTestProgram(t, fns, "Box") - generateTestProgram(t, fns, "QingStor", buildConstraint("!plan9")) - generateTestProgram(t, fns, "AzureBlob") - generateTestProgram(t, fns, "Pcloud") - generateTestProgram(t, fns, "Webdav") - generateTestProgram(t, fns, "Cache", buildConstraint("!plan9")) - log.Printf("Done") -}