MCPcopy
hub / github.com/rclone/rclone / runTestStep

Method runTestStep

cmd/bisync/bisync_test.go:660–936  ·  view source on GitHub ↗
(ctx context.Context, line string)

Source from the content-addressed store, hash-verified

658}
659
660func (b *bisyncTest) runTestStep(ctx context.Context, line string) (err error) {
661 var fsrc, fdst fs.Fs
662 ctx = accounting.WithStatsGroup(ctx, random.String(8))
663 b.logPrintf("%s %s", color(terminal.CyanFg, b.stepStr), color(terminal.BlueFg, line))
664
665 ci := fs.GetConfig(ctx)
666 ciSave := *ci
667 defer func() {
668 *ci = ciSave
669 }()
670 testFunc := func() {
671 src := filepath.Join(b.dataDir, "file7.txt")
672
673 for i := range 50 {
674 dst := "file" + fmt.Sprint(i) + ".txt"
675 err := b.copyFile(ctx, src, b.replaceHex(b.path2), dst)
676 if err != nil {
677 fs.Errorf(src, "error copying file: %v", err)
678 }
679 dst = "file" + fmt.Sprint(100-i) + ".txt"
680 err = b.copyFile(ctx, src, b.replaceHex(b.path1), dst)
681 if err != nil {
682 fs.Errorf(dst, "error copying file: %v", err)
683 }
684 }
685 }
686
687 args := splitLine(line)
688 switch args[0] {
689 case "test":
690 b.checkArgs(args, 1, 0)
691 return nil
692 case "copy-listings":
693 b.checkArgs(args, 1, 1)
694 return b.saveTestListings(args[1], true)
695 case "move-listings":
696 b.checkArgs(args, 1, 1)
697 return b.saveTestListings(args[1], false)
698 case "purge-children":
699 b.checkArgs(args, 1, 1)
700 dir := ""
701 if strings.HasPrefix(args[1], b.replaceHex(b.path1)) {
702 fsrc = b.fs1
703 dir = strings.TrimPrefix(args[1], b.replaceHex(b.path1))
704 } else if strings.HasPrefix(args[1], b.replaceHex(b.path2)) {
705 fsrc = b.fs2
706 dir = strings.TrimPrefix(args[1], b.replaceHex(b.path2))
707 } else {
708 return fmt.Errorf("error parsing arg: %q (path1: %q, path2: %q)", args[1], b.path1, b.path2)
709 }
710 return purgeChildren(ctx, fsrc, dir)
711 case "delete-file":
712 b.checkArgs(args, 1, 1)
713 dir, file := filepath.Split(args[1])
714 if fsrc, err = cache.Get(ctx, dir); err != nil {
715 return err
716 }
717 var obj fs.Object

Callers 1

runTestCaseMethod · 0.95

Calls 15

logPrintfMethod · 0.95
copyFileMethod · 0.95
replaceHexMethod · 0.95
checkArgsMethod · 0.95
saveTestListingsMethod · 0.95
NewObjectMethod · 0.95
listSubdirsMethod · 0.95
runBisyncMethod · 0.95
RootMethod · 0.95
WithStatsGroupFunction · 0.92
StringFunction · 0.92
GetConfigFunction · 0.92

Tested by

no test coverage detected