github.com/artpar/rclone@v1.67.3/backend/chunker/chunker_test.go (about) 1 // Test the Chunker filesystem interface 2 package chunker_test 3 4 import ( 5 "flag" 6 "os" 7 "path/filepath" 8 "testing" 9 10 _ "github.com/artpar/rclone/backend/all" // for integration tests 11 "github.com/artpar/rclone/backend/chunker" 12 "github.com/artpar/rclone/fstest" 13 "github.com/artpar/rclone/fstest/fstests" 14 ) 15 16 // Command line flags 17 var ( 18 // Invalid characters are not supported by some remotes, e.g. Mailru. 19 // We enable testing with invalid characters when -remote is not set, so 20 // chunker overlays a local directory, but invalid characters are disabled 21 // by default when -remote is set, e.g. when test_all runs backend tests. 22 // You can still test with invalid characters using the below flag. 23 UseBadChars = flag.Bool("bad-chars", false, "Set to test bad characters in file names when -remote is set") 24 ) 25 26 // TestIntegration runs integration tests against a concrete remote 27 // set by the -remote flag. If the flag is not set, it creates a 28 // dynamic chunker overlay wrapping a local temporary directory. 29 func TestIntegration(t *testing.T) { 30 opt := fstests.Opt{ 31 RemoteName: *fstest.RemoteName, 32 NilObject: (*chunker.Object)(nil), 33 SkipBadWindowsCharacters: !*UseBadChars, 34 UnimplementableObjectMethods: []string{ 35 "MimeType", 36 "GetTier", 37 "SetTier", 38 "Metadata", 39 }, 40 UnimplementableFsMethods: []string{ 41 "PublicLink", 42 "OpenWriterAt", 43 "OpenChunkWriter", 44 "MergeDirs", 45 "DirCacheFlush", 46 "UserInfo", 47 "Disconnect", 48 }, 49 } 50 if *fstest.RemoteName == "" { 51 name := "TestChunker" 52 opt.RemoteName = name + ":" 53 tempDir := filepath.Join(os.TempDir(), "rclone-chunker-test-standard") 54 opt.ExtraConfig = []fstests.ExtraConfigItem{ 55 {Name: name, Key: "type", Value: "chunker"}, 56 {Name: name, Key: "remote", Value: tempDir}, 57 } 58 opt.QuickTestOK = true 59 } 60 fstests.Run(t, &opt) 61 }