MCPcopy
hub / github.com/rclone/rclone / testBisync

Function testBisync

cmd/bisync/bisync_test.go:318–413  ·  view source on GitHub ↗

TestBisync is a test engine for bisync test cases.

(ctx context.Context, t *testing.T, path1, path2 string)

Source from the content-addressed store, hash-verified

316
317// TestBisync is a test engine for bisync test cases.
318func testBisync(ctx context.Context, t *testing.T, path1, path2 string) {
319 ci := fs.GetConfig(ctx)
320 ciSave := *ci
321 defer func() {
322 *ci = ciSave
323 }()
324 if *argRefreshTimes {
325 ci.RefreshTimes = true
326 }
327 bisync.ColorsLock.Lock()
328 bisync.Colors = true
329 bisync.ColorsLock.Unlock()
330 ci.FsCacheExpireDuration = fs.Duration(5 * time.Hour)
331
332 baseDir, err := os.Getwd()
333 require.NoError(t, err, "get current directory")
334 randName := time.Now().Format("150405") + random.String(8) // some bucket backends don't like dots, keep this short to avoid linux errors
335 tempDir := filepath.Join(os.TempDir(), randName)
336 workDir := filepath.Join(tempDir, "workdir")
337
338 b := &bisyncTest{
339 // per-test state
340 t: t,
341 // global state
342 tempDir: tempDir,
343 randName: randName,
344 workDir: workDir,
345 dataRoot: filepath.Join(baseDir, "testdata"),
346 logDir: filepath.Join(tempDir, "logs"),
347 logPath: filepath.Join(workDir, logFileName),
348 // global flags
349 argRemote1: path1,
350 argRemote2: path2,
351 noCompare: *argNoCompare,
352 noCleanup: *argNoCleanup,
353 golden: *argGolden,
354 debug: *argDebug,
355 stopAt: *argStopAt,
356 }
357
358 b.mkdir(b.tempDir)
359 b.mkdir(b.logDir)
360
361 fnHandle := atexit.Register(func() {
362 if atexit.Signalled() {
363 b.cleanupAll()
364 }
365 })
366 defer func() {
367 b.cleanupAll()
368 atexit.Unregister(fnHandle)
369 }()
370
371 argCase := *argTestCase
372 if argCase == "" {
373 argCase = "all"
374 if testing.Short() {
375 // remote tests can be long, help with "go test -short"

Callers 3

TestBisyncRemoteLocalFunction · 0.85
TestBisyncLocalRemoteFunction · 0.85
TestBisyncRemoteRemoteFunction · 0.85

Calls 15

mkdirMethod · 0.95
cleanupAllMethod · 0.95
listDirMethod · 0.95
GetConfigFunction · 0.92
DurationTypeAlias · 0.92
StringFunction · 0.92
RegisterFunction · 0.92
SignalledFunction · 0.92
UnregisterFunction · 0.92
FormatMethod · 0.80
JoinMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…