github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/backend/hasher/hasher_test.go (about) 1 package hasher_test 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 8 "github.com/rclone/rclone/backend/hasher" 9 "github.com/rclone/rclone/fstest" 10 "github.com/rclone/rclone/fstest/fstests" 11 "github.com/rclone/rclone/lib/kv" 12 13 _ "github.com/rclone/rclone/backend/all" // for integration tests 14 ) 15 16 // TestIntegration runs integration tests against the remote 17 func TestIntegration(t *testing.T) { 18 if !kv.Supported() { 19 t.Skip("hasher is not supported on this OS") 20 } 21 opt := fstests.Opt{ 22 RemoteName: *fstest.RemoteName, 23 NilObject: (*hasher.Object)(nil), 24 UnimplementableFsMethods: []string{ 25 "OpenWriterAt", 26 "OpenChunkWriter", 27 }, 28 UnimplementableObjectMethods: []string{}, 29 } 30 if *fstest.RemoteName == "" { 31 tempDir := filepath.Join(os.TempDir(), "rclone-hasher-test") 32 opt.ExtraConfig = []fstests.ExtraConfigItem{ 33 {Name: "TestHasher", Key: "type", Value: "hasher"}, 34 {Name: "TestHasher", Key: "remote", Value: tempDir}, 35 } 36 opt.RemoteName = "TestHasher:" 37 opt.QuickTestOK = true 38 } 39 fstests.Run(t, &opt) 40 // test again with MaxAge = 0 41 if *fstest.RemoteName == "" { 42 opt.ExtraConfig = append(opt.ExtraConfig, fstests.ExtraConfigItem{Name: "TestHasher", Key: "max_age", Value: "0"}) 43 fstests.Run(t, &opt) 44 } 45 }