MCPcopy
hub / github.com/rclone/rclone / makeTempRemote

Method makeTempRemote

cmd/bisync/bisync_test.go:622–652  ·  view source on GitHub ↗

makeTempRemote creates temporary folder and makes a filesystem if a local path is provided, it's ignored (the test will run under system temp)

(ctx context.Context, remote, subdir string)

Source from the content-addressed store, hash-verified

620// makeTempRemote creates temporary folder and makes a filesystem
621// if a local path is provided, it's ignored (the test will run under system temp)
622func (b *bisyncTest) makeTempRemote(ctx context.Context, remote, subdir string) (f, parent fs.Fs, path, canon string) {
623 var err error
624 if isLocal(remote) {
625 if remote != "" && !strings.HasPrefix(remote, "local") && *fstest.RemoteName != "" {
626 b.t.Fatalf(`Missing ":" in remote %q. Use "local" to test with local filesystem.`, remote)
627 }
628 parent, err = cache.Get(ctx, b.tempDir)
629 checkError(b.t, err, "parsing local tempdir %s", b.tempDir)
630
631 path = filepath.Join(b.tempDir, b.testCase)
632 path = filepath.Join(path, subdir)
633 } else {
634 last := remote[len(remote)-1]
635 if last != ':' && last != '/' {
636 remote += "/"
637 }
638 remote += b.randName
639 parent, err = cache.Get(ctx, remote)
640 checkError(b.t, err, "parsing remote %s", remote)
641 checkError(b.t, operations.Mkdir(ctx, parent, subdir), "Mkdir "+subdir) // ensure dir exists (storj seems to need this)
642
643 path = remote + "/" + b.testCase
644 path += "/" + subdir
645 }
646
647 f, err = cache.Get(ctx, path)
648 checkError(b.t, err, "parsing remote/subdir %s/%s", remote, subdir)
649 path = bilib.FsPath(f) // Make it canonical
650 canon = bilib.StripHexString(bilib.CanonicalPath(strings.TrimSuffix(strings.TrimSuffix(path, `\`+subdir+`\`), "/"+subdir+"/"))) + "_" // account for possible connection string
651 return
652}
653
654func (b *bisyncTest) cleanupCase(ctx context.Context) {
655 _ = operations.Purge(ctx, b.fs1, "")

Callers 1

runTestCaseMethod · 0.95

Calls 9

GetFunction · 0.92
MkdirFunction · 0.92
FsPathFunction · 0.92
StripHexStringFunction · 0.92
CanonicalPathFunction · 0.92
isLocalFunction · 0.85
checkErrorFunction · 0.85
FatalfMethod · 0.80
JoinMethod · 0.80

Tested by

no test coverage detected