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