2019-06-09 19:41:48 +02:00
|
|
|
// Test the Chunker filesystem interface
|
|
|
|
package chunker_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
_ "github.com/rclone/rclone/backend/all" // for integration tests
|
|
|
|
"github.com/rclone/rclone/backend/chunker"
|
|
|
|
"github.com/rclone/rclone/fstest"
|
|
|
|
"github.com/rclone/rclone/fstest/fstests"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Command line flags
|
|
|
|
var (
|
2020-10-13 23:49:58 +02:00
|
|
|
// Invalid characters are not supported by some remotes, e.g. Mailru.
|
2019-06-09 19:41:48 +02:00
|
|
|
// We enable testing with invalid characters when -remote is not set, so
|
|
|
|
// chunker overlays a local directory, but invalid characters are disabled
|
2020-10-13 23:49:58 +02:00
|
|
|
// by default when -remote is set, e.g. when test_all runs backend tests.
|
2019-06-09 19:41:48 +02:00
|
|
|
// You can still test with invalid characters using the below flag.
|
|
|
|
UseBadChars = flag.Bool("bad-chars", false, "Set to test bad characters in file names when -remote is set")
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestIntegration runs integration tests against a concrete remote
|
|
|
|
// set by the -remote flag. If the flag is not set, it creates a
|
|
|
|
// dynamic chunker overlay wrapping a local temporary directory.
|
|
|
|
func TestIntegration(t *testing.T) {
|
|
|
|
opt := fstests.Opt{
|
2019-09-25 01:18:30 +02:00
|
|
|
RemoteName: *fstest.RemoteName,
|
|
|
|
NilObject: (*chunker.Object)(nil),
|
|
|
|
SkipBadWindowsCharacters: !*UseBadChars,
|
|
|
|
UnimplementableObjectMethods: []string{
|
|
|
|
"MimeType",
|
|
|
|
"GetTier",
|
|
|
|
"SetTier",
|
2022-06-29 15:27:43 +02:00
|
|
|
"Metadata",
|
2019-09-25 01:18:30 +02:00
|
|
|
},
|
2019-06-09 19:41:48 +02:00
|
|
|
UnimplementableFsMethods: []string{
|
|
|
|
"PublicLink",
|
|
|
|
"OpenWriterAt",
|
|
|
|
"MergeDirs",
|
|
|
|
"DirCacheFlush",
|
|
|
|
"UserInfo",
|
|
|
|
"Disconnect",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
if *fstest.RemoteName == "" {
|
|
|
|
name := "TestChunker"
|
|
|
|
opt.RemoteName = name + ":"
|
|
|
|
tempDir := filepath.Join(os.TempDir(), "rclone-chunker-test-standard")
|
|
|
|
opt.ExtraConfig = []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "chunker"},
|
|
|
|
{Name: name, Key: "remote", Value: tempDir},
|
|
|
|
}
|
2022-06-29 12:51:46 +02:00
|
|
|
opt.QuickTestOK = true
|
2019-06-09 19:41:48 +02:00
|
|
|
}
|
|
|
|
fstests.Run(t, &opt)
|
|
|
|
}
|