2021-10-12 14:16:39 +02:00
|
|
|
package hasher_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/rclone/rclone/backend/hasher"
|
|
|
|
"github.com/rclone/rclone/fstest"
|
|
|
|
"github.com/rclone/rclone/fstest/fstests"
|
|
|
|
"github.com/rclone/rclone/lib/kv"
|
|
|
|
|
|
|
|
_ "github.com/rclone/rclone/backend/all" // for integration tests
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestIntegration runs integration tests against the remote
|
|
|
|
func TestIntegration(t *testing.T) {
|
|
|
|
if !kv.Supported() {
|
|
|
|
t.Skip("hasher is not supported on this OS")
|
|
|
|
}
|
|
|
|
opt := fstests.Opt{
|
|
|
|
RemoteName: *fstest.RemoteName,
|
|
|
|
NilObject: (*hasher.Object)(nil),
|
|
|
|
UnimplementableFsMethods: []string{
|
|
|
|
"OpenWriterAt",
|
2023-07-13 21:01:10 +02:00
|
|
|
"OpenChunkWriter",
|
2021-10-12 14:16:39 +02:00
|
|
|
},
|
|
|
|
UnimplementableObjectMethods: []string{},
|
|
|
|
}
|
|
|
|
if *fstest.RemoteName == "" {
|
|
|
|
tempDir := filepath.Join(os.TempDir(), "rclone-hasher-test")
|
|
|
|
opt.ExtraConfig = []fstests.ExtraConfigItem{
|
|
|
|
{Name: "TestHasher", Key: "type", Value: "hasher"},
|
|
|
|
{Name: "TestHasher", Key: "remote", Value: tempDir},
|
|
|
|
}
|
|
|
|
opt.RemoteName = "TestHasher:"
|
2022-06-29 12:51:46 +02:00
|
|
|
opt.QuickTestOK = true
|
2021-10-12 14:16:39 +02:00
|
|
|
}
|
|
|
|
fstests.Run(t, &opt)
|
2023-12-21 20:06:06 +01:00
|
|
|
// test again with MaxAge = 0
|
|
|
|
if *fstest.RemoteName == "" {
|
|
|
|
opt.ExtraConfig = append(opt.ExtraConfig, fstests.ExtraConfigItem{Name: "TestHasher", Key: "max_age", Value: "0"})
|
|
|
|
fstests.Run(t, &opt)
|
|
|
|
}
|
2021-10-12 14:16:39 +02:00
|
|
|
}
|