當前位置: 首頁>>代碼示例>>Golang>>正文


Golang fstest.RandomRemote函數代碼示例

本文整理匯總了Golang中github.com/ncw/rclone/fstest.RandomRemote函數的典型用法代碼示例。如果您正苦於以下問題:Golang RandomRemote函數的具體用法?Golang RandomRemote怎麽用?Golang RandomRemote使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了RandomRemote函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: newRun

// newRun initialise the remote and local for testing and returns a
// run object.
//
// r.flocal is an empty local Fs
// r.fremote is an empty remote Fs
//
// Finalise() will tidy them away when done.
func newRun() *Run {
	r := &Run{
		Logf:   log.Printf,
		Fatalf: log.Fatalf,
		mkdir:  make(map[string]bool),
	}

	fs.LoadConfig()
	fs.Config.Verbose = *Verbose
	fs.Config.Quiet = !*Verbose
	fs.Config.DumpHeaders = *DumpHeaders
	fs.Config.DumpBodies = *DumpBodies

	var err error
	r.fremote, r.cleanRemote, err = fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		r.Fatalf("Failed to open remote %q: %v", *RemoteName, err)
	}

	r.localName, err = ioutil.TempDir("", "rclone")
	if err != nil {
		r.Fatalf("Failed to create temp dir: %v", err)
	}
	r.localName = filepath.ToSlash(r.localName)
	r.flocal, err = fs.NewFs(r.localName)
	if err != nil {
		r.Fatalf("Failed to make %q: %v", r.localName, err)
	}
	fs.CalculateModifyWindow(r.fremote, r.flocal)
	return r
}
開發者ID:vanphong3783,項目名稱:rclone,代碼行數:38,代碼來源:operations_test.go

示例2: TestFsDirMove

// TestFsDirMove tests DirMove
func TestFsDirMove(t *testing.T) {
	skipIfNotOk(t)

	// Check have DirMove
	_, ok := remote.(fs.DirMover)
	if !ok {
		t.Skip("FS has no DirMover interface")
	}

	// Check it can't move onto itself
	err := remote.(fs.DirMover).DirMove(remote)
	require.Equal(t, fs.ErrorDirExists, err)

	// new remote
	newRemote, _, removeNewRemote, err := fstest.RandomRemote(RemoteName, false)
	require.NoError(t, err)
	defer removeNewRemote()

	// try the move
	err = newRemote.(fs.DirMover).DirMove(remote)
	require.NoError(t, err)

	// check remotes
	// FIXME: Prints errors.
	fstest.CheckListing(t, remote, []fstest.Item{})
	fstest.CheckListing(t, newRemote, []fstest.Item{file2, file1})

	// move it back
	err = remote.(fs.DirMover).DirMove(newRemote)
	require.NoError(t, err)

	// check remotes
	fstest.CheckListing(t, remote, []fstest.Item{file2, file1})
	fstest.CheckListing(t, newRemote, []fstest.Item{})
}
開發者ID:pombredanne,項目名稱:rclone,代碼行數:36,代碼來源:fstests.go

示例3: TestServerSideMove

// Test a server side move if possible, or the backup path if not
func TestServerSideMove(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteBoth("potato2", "------------------------------------------------------------", t1)
	file2 := r.WriteBoth("empty space", "", t2)

	fstest.CheckItems(t, r.fremote, file2, file1)

	fremoteMove, finaliseMove, err := fstest.RandomRemote(*RemoteName, *SubDir)
	require.NoError(t, err)
	defer finaliseMove()
	t.Logf("Server side move (if possible) %v -> %v", r.fremote, fremoteMove)

	// Write just one file in the new remote
	r.WriteObjectTo(fremoteMove, "empty space", "", t2, false)
	fstest.CheckItems(t, fremoteMove, file2)

	// Do server side move
	fs.Stats.ResetCounters()
	err = fs.MoveDir(fremoteMove, r.fremote)
	require.NoError(t, err)

	fstest.CheckItems(t, r.fremote)
	fstest.CheckItems(t, fremoteMove, file2, file1)

	// Move it back again, dst does not exist this time
	fs.Stats.ResetCounters()
	err = fs.MoveDir(r.fremote, fremoteMove)
	require.NoError(t, err)

	fstest.CheckItems(t, r.fremote, file2, file1)
	fstest.CheckItems(t, fremoteMove)
}
開發者ID:yut148,項目名稱:rclone,代碼行數:34,代碼來源:sync_test.go

示例4: TestInit

func TestInit(t *testing.T) {
	fs.LoadConfig()
	fs.Config.Verbose = *Verbose
	fs.Config.Quiet = !*Verbose
	fs.Config.DumpHeaders = *DumpHeaders
	fs.Config.DumpBodies = *DumpBodies
	var err error
	fremote, finalise, err = fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote %q: %v", *RemoteName, err)
	}
	t.Logf("Testing with remote %v", fremote)

	localName, err = ioutil.TempDir("", "rclone")
	if err != nil {
		t.Fatalf("Failed to create temp dir: %v", err)
	}
	localName = filepath.ToSlash(localName)
	t.Logf("Testing with local %q", localName)
	flocal, err = fs.NewFs(localName)
	if err != nil {
		t.Fatalf("Failed to make %q: %v", remoteName, err)
	}

}
開發者ID:vlinhd11,項目名稱:rclone,代碼行數:25,代碼來源:operations_test.go

示例5: newRun

// newRun initialise the remote mount for testing and returns a run
// object.
//
// r.fremote is an empty remote Fs
//
// Finalise() will tidy them away when done.
func newRun() *Run {
	r := &Run{
		umountResult: make(chan error, 1),
	}

	// Never ask for passwords, fail instead.
	// If your local config is encrypted set environment variable
	// "RCLONE_CONFIG_PASS=hunter2" (or your password)
	*fs.AskPassword = false
	fs.LoadConfig()
	fs.Config.Verbose = *Verbose
	fs.Config.Quiet = !*Verbose
	fs.Config.DumpHeaders = *DumpHeaders
	fs.Config.DumpBodies = *DumpBodies
	fs.Config.LowLevelRetries = *LowLevelRetries
	var err error
	r.fremote, r.fremoteName, r.cleanRemote, err = fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		log.Fatalf("Failed to open remote %q: %v", *RemoteName, err)
	}

	r.mountPath, err = ioutil.TempDir("", "rclonefs-mount")
	if err != nil {
		log.Fatalf("Failed to create mount dir: %v", err)
	}

	// Mount it up
	r.mount()

	return r
}
開發者ID:marcopaganini,項目名稱:rclone,代碼行數:37,代碼來源:fs_test.go

示例6: newRun

// newRun initialise the remote and local for testing and returns a
// run object.
//
// r.flocal is an empty local Fs
// r.fremote is an empty remote Fs
//
// Finalise() will tidy them away when done.
func newRun() *Run {
	r := &Run{
		Logf:   log.Printf,
		Fatalf: log.Fatalf,
		mkdir:  make(map[string]bool),
	}

	// Never ask for passwords, fail instead.
	// If your local config is encrypted set environment variable
	// "RCLONE_CONFIG_PASS=hunter2" (or your password)
	*fs.AskPassword = false
	fs.LoadConfig()
	fs.Config.Verbose = *Verbose
	fs.Config.Quiet = !*Verbose
	fs.Config.DumpHeaders = *DumpHeaders
	fs.Config.DumpBodies = *DumpBodies
	fs.Config.LowLevelRetries = *LowLevelRetries
	var err error
	r.fremote, r.cleanRemote, err = fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		r.Fatalf("Failed to open remote %q: %v", *RemoteName, err)
	}

	r.localName, err = ioutil.TempDir("", "rclone")
	if err != nil {
		r.Fatalf("Failed to create temp dir: %v", err)
	}
	r.localName = filepath.ToSlash(r.localName)
	r.flocal, err = fs.NewFs(r.localName)
	if err != nil {
		r.Fatalf("Failed to make %q: %v", r.localName, err)
	}
	fs.CalculateModifyWindow(r.fremote, r.flocal)
	return r
}
開發者ID:yut148,項目名稱:rclone,代碼行數:42,代碼來源:operations_test.go

示例7: TestServerSideMove

// Test a server side move if possible, or the backup path if not
func TestServerSideMove(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	fremoteMove, _, finaliseMove, err := fstest.RandomRemote(*RemoteName, *SubDir)
	require.NoError(t, err)
	defer finaliseMove()
	testServerSideMove(t, r, fremoteMove, false)
}
開發者ID:marcopaganini,項目名稱:rclone,代碼行數:9,代碼來源:sync_test.go

示例8: TestServerSideMoveWithFilter

// Test a server side move if possible, or the backup path if not
func TestServerSideMoveWithFilter(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()

	fs.Config.Filter.MinSize = 40
	defer func() {
		fs.Config.Filter.MinSize = -1
	}()

	fremoteMove, _, finaliseMove, err := fstest.RandomRemote(*RemoteName, *SubDir)
	require.NoError(t, err)
	defer finaliseMove()
	testServerSideMove(t, r, fremoteMove, true)
}
開發者ID:marcopaganini,項目名稱:rclone,代碼行數:15,代碼來源:sync_test.go

示例9: TestServerSideCopy

// Test a server side copy if possible, or the backup path if not
func TestServerSideCopy(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteObject("sub dir/hello world", "hello world", t1)
	fstest.CheckItems(t, r.fremote, file1)

	fremoteCopy, _, finaliseCopy, err := fstest.RandomRemote(*RemoteName, *SubDir)
	require.NoError(t, err)
	defer finaliseCopy()
	t.Logf("Server side copy (if possible) %v -> %v", r.fremote, fremoteCopy)

	err = fs.CopyDir(fremoteCopy, r.fremote)
	require.NoError(t, err)

	fstest.CheckItems(t, fremoteCopy, file1)
}
開發者ID:marcopaganini,項目名稱:rclone,代碼行數:17,代碼來源:sync_test.go

示例10: TestServerSideMove

// Test a server side move if possible, or the backup path if not
func TestServerSideMove(t *testing.T) {
	fremoteMove, finaliseMove, err := fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote move %q: %v", *RemoteName, err)
	}
	defer finaliseMove()
	t.Logf("Server side move (if possible) %v -> %v", fremote, fremoteMove)

	// Start with a copy
	err = fs.CopyDir(fremoteMove, fremote)
	if err != nil {
		t.Fatalf("Server Side Copy failed: %v", err)
	}

	// Remove one file
	obj := fremoteMove.NewFsObject("potato2")
	if obj == nil {
		t.Fatalf("Failed to find potato2")
	}
	err = obj.Remove()
	if err != nil {
		t.Fatalf("Failed to remove object: %v", err)
	}

	// Do server side move
	err = fs.MoveDir(fremoteMove, fremote)
	if err != nil {
		t.Fatalf("Server Side Move failed: %v", err)
	}

	items := []fstest.Item{
		{Path: "empty space", Size: 0, ModTime: t2, Md5sum: "d41d8cd98f00b204e9800998ecf8427e"},
		{Path: "potato2", Size: 60, ModTime: t1, Md5sum: "d6548b156ea68a4e003e786df99eee76"},
	}

	fstest.CheckListingWithPrecision(t, fremote, items[:0], fs.Config.ModifyWindow)
	fstest.CheckListingWithPrecision(t, fremoteMove, items, fs.Config.ModifyWindow)

	// Move it back again, dst does not exist this time
	err = fs.MoveDir(fremote, fremoteMove)
	if err != nil {
		t.Fatalf("Server Side Move 2 failed: %v", err)
	}

	fstest.CheckListingWithPrecision(t, fremote, items, fs.Config.ModifyWindow)
	fstest.CheckListingWithPrecision(t, fremoteMove, items[:0], fs.Config.ModifyWindow)
}
開發者ID:vlinhd11,項目名稱:rclone,代碼行數:48,代碼來源:operations_test.go

示例11: TestFsDirMove

// TestFsDirMove tests DirMove
func TestFsDirMove(t *testing.T) {
	skipIfNotOk(t)

	// Check have DirMove
	_, ok := remote.(fs.DirMover)
	if !ok {
		t.Skip("FS has no DirMover interface")
	}

	// Check it can't move onto itself
	err := remote.(fs.DirMover).DirMove(remote)
	if err != fs.ErrorDirExists {
		t.Errorf("Expecting fs.ErrorDirExists got: %v", err)
	}

	// new remote
	newRemote, removeNewRemote, err := fstest.RandomRemote(RemoteName, false)
	if err != nil {
		t.Fatalf("Failed to create remote: %v", err)
	}
	defer removeNewRemote()

	// try the move
	err = newRemote.(fs.DirMover).DirMove(remote)
	if err != nil {
		t.Errorf("Failed to DirMove: %v", err)
	}

	// check remotes
	// FIXME: Prints errors.
	fstest.CheckListing(t, remote, []fstest.Item{})
	fstest.CheckListing(t, newRemote, []fstest.Item{file2, file1})

	// move it back
	err = remote.(fs.DirMover).DirMove(newRemote)
	if err != nil {
		t.Errorf("Failed to DirMove: %v", err)
	}

	// check remotes
	fstest.CheckListing(t, remote, []fstest.Item{file2, file1})
	fstest.CheckListing(t, newRemote, []fstest.Item{})
}
開發者ID:nicot,項目名稱:rclone,代碼行數:44,代碼來源:fstests.go

示例12: TestServerSideCopy

// Test a server side copy if possible, or the backup path if not
func TestServerSideCopy(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteObject("sub dir/hello world", "hello world", t1)
	fstest.CheckItems(t, r.fremote, file1)

	fremoteCopy, finaliseCopy, err := fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote copy %q: %v", *RemoteName, err)
	}
	defer finaliseCopy()
	t.Logf("Server side copy (if possible) %v -> %v", r.fremote, fremoteCopy)

	err = fs.CopyDir(fremoteCopy, r.fremote)
	if err != nil {
		t.Fatalf("Server Side Copy failed: %v", err)
	}

	fstest.CheckItems(t, fremoteCopy, file1)
}
開發者ID:vanphong3783,項目名稱:rclone,代碼行數:21,代碼來源:operations_test.go

示例13: TestServerSideCopy

// Test a server side copy if possible, or the backup path if not
func TestServerSideCopy(t *testing.T) {
	fremoteCopy, finaliseCopy, err := fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote copy %q: %v", *RemoteName, err)
	}
	defer finaliseCopy()
	t.Logf("Server side copy (if possible) %v -> %v", fremote, fremoteCopy)

	err = fs.CopyDir(fremoteCopy, fremote)
	if err != nil {
		t.Fatalf("Server Side Copy failed: %v", err)
	}

	items := []fstest.Item{
		{Path: "sub dir/hello world", Size: 11, ModTime: t1, Md5sum: "5eb63bbbe01eeed093cb22bb8f5acdc3"},
	}

	fstest.CheckListingWithPrecision(t, fremote, items, fs.Config.ModifyWindow)
	fstest.CheckListingWithPrecision(t, fremoteCopy, items, fs.Config.ModifyWindow)
}
開發者ID:vlinhd11,項目名稱:rclone,代碼行數:21,代碼來源:operations_test.go

示例14: TestServerSideMove

// Test a server side move if possible, or the backup path if not
func TestServerSideMove(t *testing.T) {
	r := NewRun(t)
	defer r.Finalise()
	file1 := r.WriteBoth("potato2", "------------------------------------------------------------", t1)
	file2 := r.WriteBoth("empty space", "", t2)

	fstest.CheckItems(t, r.fremote, file2, file1)

	fremoteMove, finaliseMove, err := fstest.RandomRemote(*RemoteName, *SubDir)
	if err != nil {
		t.Fatalf("Failed to open remote move %q: %v", *RemoteName, err)
	}
	defer finaliseMove()
	t.Logf("Server side move (if possible) %v -> %v", r.fremote, fremoteMove)

	// Write just one file in the new remote
	r.WriteObjectTo(fremoteMove, "empty space", "", t2)
	fstest.CheckItems(t, fremoteMove, file2)

	// Do server side move
	err = fs.MoveDir(fremoteMove, r.fremote)
	if err != nil {
		t.Fatalf("Server Side Move failed: %v", err)
	}

	fstest.CheckItems(t, r.fremote)
	fstest.CheckItems(t, fremoteMove, file2, file1)

	// Move it back again, dst does not exist this time
	err = fs.MoveDir(r.fremote, fremoteMove)
	if err != nil {
		t.Fatalf("Server Side Move 2 failed: %v", err)
	}

	fstest.CheckItems(t, r.fremote, file2, file1)
	fstest.CheckItems(t, fremoteMove)
}
開發者ID:vanphong3783,項目名稱:rclone,代碼行數:38,代碼來源:operations_test.go


注:本文中的github.com/ncw/rclone/fstest.RandomRemote函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。