mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 14:51:48 +08:00
parent
d846210978
commit
d69b96a94c
8
fs/cache/cache_test.go
vendored
8
fs/cache/cache_test.go
vendored
|
@ -23,9 +23,9 @@ func mockNewFs(t *testing.T) (func(), func(ctx context.Context, path string) (fs
|
||||||
called++
|
called++
|
||||||
switch path {
|
switch path {
|
||||||
case "mock:/":
|
case "mock:/":
|
||||||
return mockfs.NewFs("mock", "/"), nil
|
return mockfs.NewFs(ctx, "mock", "/"), nil
|
||||||
case "mock:/file.txt", "mock:file.txt":
|
case "mock:/file.txt", "mock:file.txt":
|
||||||
return mockfs.NewFs("mock", "/"), fs.ErrorIsFile
|
return mockfs.NewFs(ctx, "mock", "/"), fs.ErrorIsFile
|
||||||
case "mock:/error":
|
case "mock:/error":
|
||||||
return nil, errSentinel
|
return nil, errSentinel
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func TestPut(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
cleanup, create := mockNewFs(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
f := mockfs.NewFs("mock", "/alien")
|
f := mockfs.NewFs(context.Background(), "mock", "/alien")
|
||||||
|
|
||||||
assert.Equal(t, 0, c.Entries())
|
assert.Equal(t, 0, c.Entries())
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ func TestPin(t *testing.T) {
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// Test pinning and unpinning non existent
|
// Test pinning and unpinning non existent
|
||||||
f := mockfs.NewFs("mock", "/alien")
|
f := mockfs.NewFs(context.Background(), "mock", "/alien")
|
||||||
Pin(f)
|
Pin(f)
|
||||||
Unpin(f)
|
Unpin(f)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
func TestFingerprint(t *testing.T) {
|
func TestFingerprint(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
f := mockfs.NewFs("test", "root")
|
f := mockfs.NewFs(ctx, "test", "root")
|
||||||
f.SetHashes(hash.NewHashSet(hash.MD5))
|
f.SetHashes(hash.NewHashSet(hash.MD5))
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
|
|
|
@ -17,9 +17,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDoMultiThreadCopy(t *testing.T) {
|
func TestDoMultiThreadCopy(t *testing.T) {
|
||||||
f := mockfs.NewFs("potato", "")
|
f := mockfs.NewFs(context.Background(), "potato", "")
|
||||||
src := mockobject.New("file.txt").WithContent([]byte(random.String(100)), mockobject.SeekModeNone)
|
src := mockobject.New("file.txt").WithContent([]byte(random.String(100)), mockobject.SeekModeNone)
|
||||||
srcFs := mockfs.NewFs("sausage", "")
|
srcFs := mockfs.NewFs(context.Background(), "sausage", "")
|
||||||
src.SetFs(srcFs)
|
src.SetFs(srcFs)
|
||||||
|
|
||||||
oldStreams := fs.Config.MultiThreadStreams
|
oldStreams := fs.Config.MultiThreadStreams
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func mockNewFs(t *testing.T) func() {
|
func mockNewFs(t *testing.T) func() {
|
||||||
f := mockfs.NewFs("mock", "mock")
|
f := mockfs.NewFs(context.Background(), "mock", "mock")
|
||||||
cache.Put("/", f)
|
cache.Put("/", f)
|
||||||
return func() {
|
return func() {
|
||||||
cache.Clear()
|
cache.Clear()
|
||||||
|
|
|
@ -709,7 +709,7 @@ func TestListR(t *testing.T) {
|
||||||
mockobject.Object("dir/b"),
|
mockobject.Object("dir/b"),
|
||||||
mockobject.Object("dir/c"),
|
mockobject.Object("dir/c"),
|
||||||
}
|
}
|
||||||
f := mockfs.NewFs("mock", "/")
|
f := mockfs.NewFs(context.Background(), "mock", "/")
|
||||||
var got []string
|
var got []string
|
||||||
clearCallback := func() {
|
clearCallback := func() {
|
||||||
got = nil
|
got = nil
|
||||||
|
|
|
@ -25,12 +25,12 @@ type Fs struct {
|
||||||
var ErrNotImplemented = errors.New("not implemented")
|
var ErrNotImplemented = errors.New("not implemented")
|
||||||
|
|
||||||
// NewFs returns a new mock Fs
|
// NewFs returns a new mock Fs
|
||||||
func NewFs(name, root string) *Fs {
|
func NewFs(ctx context.Context, name, root string) *Fs {
|
||||||
f := &Fs{
|
f := &Fs{
|
||||||
name: name,
|
name: name,
|
||||||
root: root,
|
root: root,
|
||||||
}
|
}
|
||||||
f.features = (&fs.Features{}).Fill(f)
|
f.features = (&fs.Features{}).Fill(ctx, f)
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ func TestFileOpenReadUnknownSize(t *testing.T) {
|
||||||
assert.Equal(t, int64(-1), o.Size())
|
assert.Equal(t, int64(-1), o.Size())
|
||||||
|
|
||||||
// add it to a mock fs
|
// add it to a mock fs
|
||||||
f := mockfs.NewFs("test", "root")
|
f := mockfs.NewFs(context.Background(), "test", "root")
|
||||||
f.AddObject(o)
|
f.AddObject(o)
|
||||||
testObj, err := f.NewObject(ctx, remote)
|
testObj, err := f.NewObject(ctx, remote)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user