test: replace defer cleanup with t.Cleanup
Reference: https://pkg.go.dev/testing#T.Cleanup Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
parent
be783a1856
commit
8e507075d1
34 changed files with 217 additions and 555 deletions
61
backend/cache/cache_internal_test.go
vendored
61
backend/cache/cache_internal_test.go
vendored
|
@ -101,14 +101,12 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
func TestInternalListRootAndInnerRemotes(t *testing.T) {
|
func TestInternalListRootAndInnerRemotes(t *testing.T) {
|
||||||
id := fmt.Sprintf("tilrair%v", time.Now().Unix())
|
id := fmt.Sprintf("tilrair%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
// Instantiate inner fs
|
// Instantiate inner fs
|
||||||
innerFolder := "inner"
|
innerFolder := "inner"
|
||||||
runInstance.mkdir(t, rootFs, innerFolder)
|
runInstance.mkdir(t, rootFs, innerFolder)
|
||||||
rootFs2, boltDb2 := runInstance.newCacheFs(t, remoteName, id+"/"+innerFolder, true, true, nil, nil)
|
rootFs2, _ := runInstance.newCacheFs(t, remoteName, id+"/"+innerFolder, true, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs2, boltDb2)
|
|
||||||
|
|
||||||
runInstance.writeObjectString(t, rootFs2, "one", "content")
|
runInstance.writeObjectString(t, rootFs2, "one", "content")
|
||||||
listRoot, err := runInstance.list(t, rootFs, "")
|
listRoot, err := runInstance.list(t, rootFs, "")
|
||||||
|
@ -225,8 +223,7 @@ func TestInternalVfsCache(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalObjWrapFsFound(t *testing.T) {
|
func TestInternalObjWrapFsFound(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiowff%v", time.Now().Unix())
|
id := fmt.Sprintf("tiowff%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
cfs, err := runInstance.getCacheFs(rootFs)
|
cfs, err := runInstance.getCacheFs(rootFs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -258,8 +255,7 @@ func TestInternalObjWrapFsFound(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalObjNotFound(t *testing.T) {
|
func TestInternalObjNotFound(t *testing.T) {
|
||||||
id := fmt.Sprintf("tionf%v", time.Now().Unix())
|
id := fmt.Sprintf("tionf%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
obj, err := rootFs.NewObject(context.Background(), "404")
|
obj, err := rootFs.NewObject(context.Background(), "404")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
@ -269,8 +265,7 @@ func TestInternalObjNotFound(t *testing.T) {
|
||||||
func TestInternalCachedWrittenContentMatches(t *testing.T) {
|
func TestInternalCachedWrittenContentMatches(t *testing.T) {
|
||||||
testy.SkipUnreliable(t)
|
testy.SkipUnreliable(t)
|
||||||
id := fmt.Sprintf("ticwcm%v", time.Now().Unix())
|
id := fmt.Sprintf("ticwcm%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
cfs, err := runInstance.getCacheFs(rootFs)
|
cfs, err := runInstance.getCacheFs(rootFs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -297,8 +292,7 @@ func TestInternalDoubleWrittenContentMatches(t *testing.T) {
|
||||||
t.Skip("Skip test on windows/386")
|
t.Skip("Skip test on windows/386")
|
||||||
}
|
}
|
||||||
id := fmt.Sprintf("tidwcm%v", time.Now().Unix())
|
id := fmt.Sprintf("tidwcm%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
// write the object
|
// write the object
|
||||||
runInstance.writeRemoteString(t, rootFs, "one", "one content")
|
runInstance.writeRemoteString(t, rootFs, "one", "one content")
|
||||||
|
@ -316,8 +310,7 @@ func TestInternalDoubleWrittenContentMatches(t *testing.T) {
|
||||||
func TestInternalCachedUpdatedContentMatches(t *testing.T) {
|
func TestInternalCachedUpdatedContentMatches(t *testing.T) {
|
||||||
testy.SkipUnreliable(t)
|
testy.SkipUnreliable(t)
|
||||||
id := fmt.Sprintf("ticucm%v", time.Now().Unix())
|
id := fmt.Sprintf("ticucm%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// create some rand test data
|
// create some rand test data
|
||||||
|
@ -346,8 +339,7 @@ func TestInternalCachedUpdatedContentMatches(t *testing.T) {
|
||||||
func TestInternalWrappedWrittenContentMatches(t *testing.T) {
|
func TestInternalWrappedWrittenContentMatches(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiwwcm%v", time.Now().Unix())
|
id := fmt.Sprintf("tiwwcm%v", time.Now().Unix())
|
||||||
vfsflags.Opt.DirCacheTime = time.Second
|
vfsflags.Opt.DirCacheTime = time.Second
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
if runInstance.rootIsCrypt {
|
if runInstance.rootIsCrypt {
|
||||||
t.Skip("test skipped with crypt remote")
|
t.Skip("test skipped with crypt remote")
|
||||||
}
|
}
|
||||||
|
@ -377,8 +369,7 @@ func TestInternalWrappedWrittenContentMatches(t *testing.T) {
|
||||||
func TestInternalLargeWrittenContentMatches(t *testing.T) {
|
func TestInternalLargeWrittenContentMatches(t *testing.T) {
|
||||||
id := fmt.Sprintf("tilwcm%v", time.Now().Unix())
|
id := fmt.Sprintf("tilwcm%v", time.Now().Unix())
|
||||||
vfsflags.Opt.DirCacheTime = time.Second
|
vfsflags.Opt.DirCacheTime = time.Second
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
if runInstance.rootIsCrypt {
|
if runInstance.rootIsCrypt {
|
||||||
t.Skip("test skipped with crypt remote")
|
t.Skip("test skipped with crypt remote")
|
||||||
}
|
}
|
||||||
|
@ -404,8 +395,7 @@ func TestInternalLargeWrittenContentMatches(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalWrappedFsChangeNotSeen(t *testing.T) {
|
func TestInternalWrappedFsChangeNotSeen(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiwfcns%v", time.Now().Unix())
|
id := fmt.Sprintf("tiwfcns%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
cfs, err := runInstance.getCacheFs(rootFs)
|
cfs, err := runInstance.getCacheFs(rootFs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -459,8 +449,7 @@ func TestInternalWrappedFsChangeNotSeen(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalMoveWithNotify(t *testing.T) {
|
func TestInternalMoveWithNotify(t *testing.T) {
|
||||||
id := fmt.Sprintf("timwn%v", time.Now().Unix())
|
id := fmt.Sprintf("timwn%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
if !runInstance.wrappedIsExternal {
|
if !runInstance.wrappedIsExternal {
|
||||||
t.Skipf("Not external")
|
t.Skipf("Not external")
|
||||||
}
|
}
|
||||||
|
@ -546,8 +535,7 @@ func TestInternalMoveWithNotify(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalNotifyCreatesEmptyParts(t *testing.T) {
|
func TestInternalNotifyCreatesEmptyParts(t *testing.T) {
|
||||||
id := fmt.Sprintf("tincep%v", time.Now().Unix())
|
id := fmt.Sprintf("tincep%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
if !runInstance.wrappedIsExternal {
|
if !runInstance.wrappedIsExternal {
|
||||||
t.Skipf("Not external")
|
t.Skipf("Not external")
|
||||||
}
|
}
|
||||||
|
@ -633,8 +621,7 @@ func TestInternalNotifyCreatesEmptyParts(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalChangeSeenAfterDirCacheFlush(t *testing.T) {
|
func TestInternalChangeSeenAfterDirCacheFlush(t *testing.T) {
|
||||||
id := fmt.Sprintf("ticsadcf%v", time.Now().Unix())
|
id := fmt.Sprintf("ticsadcf%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
cfs, err := runInstance.getCacheFs(rootFs)
|
cfs, err := runInstance.getCacheFs(rootFs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -666,8 +653,7 @@ func TestInternalChangeSeenAfterDirCacheFlush(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalCacheWrites(t *testing.T) {
|
func TestInternalCacheWrites(t *testing.T) {
|
||||||
id := "ticw"
|
id := "ticw"
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, map[string]string{"writes": "true"})
|
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, map[string]string{"writes": "true"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
cfs, err := runInstance.getCacheFs(rootFs)
|
cfs, err := runInstance.getCacheFs(rootFs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -688,8 +674,7 @@ func TestInternalMaxChunkSizeRespected(t *testing.T) {
|
||||||
t.Skip("Skip test on windows/386")
|
t.Skip("Skip test on windows/386")
|
||||||
}
|
}
|
||||||
id := fmt.Sprintf("timcsr%v", time.Now().Unix())
|
id := fmt.Sprintf("timcsr%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil, map[string]string{"workers": "1"})
|
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, map[string]string{"workers": "1"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
cfs, err := runInstance.getCacheFs(rootFs)
|
cfs, err := runInstance.getCacheFs(rootFs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -724,8 +709,7 @@ func TestInternalMaxChunkSizeRespected(t *testing.T) {
|
||||||
func TestInternalExpiredEntriesRemoved(t *testing.T) {
|
func TestInternalExpiredEntriesRemoved(t *testing.T) {
|
||||||
id := fmt.Sprintf("tieer%v", time.Now().Unix())
|
id := fmt.Sprintf("tieer%v", time.Now().Unix())
|
||||||
vfsflags.Opt.DirCacheTime = time.Second * 4 // needs to be lower than the defined
|
vfsflags.Opt.DirCacheTime = time.Second * 4 // needs to be lower than the defined
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true, map[string]string{"info_age": "5s"}, nil)
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true, nil)
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
cfs, err := runInstance.getCacheFs(rootFs)
|
cfs, err := runInstance.getCacheFs(rootFs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -762,9 +746,7 @@ func TestInternalBug2117(t *testing.T) {
|
||||||
vfsflags.Opt.DirCacheTime = time.Second * 10
|
vfsflags.Opt.DirCacheTime = time.Second * 10
|
||||||
|
|
||||||
id := fmt.Sprintf("tib2117%v", time.Now().Unix())
|
id := fmt.Sprintf("tib2117%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, nil,
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, false, true, map[string]string{"info_age": "72h", "chunk_clean_interval": "15m"})
|
||||||
map[string]string{"info_age": "72h", "chunk_clean_interval": "15m"})
|
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
if runInstance.rootIsCrypt {
|
if runInstance.rootIsCrypt {
|
||||||
t.Skipf("skipping crypt")
|
t.Skipf("skipping crypt")
|
||||||
|
@ -865,7 +847,7 @@ func (r *run) encryptRemoteIfNeeded(t *testing.T, remote string) string {
|
||||||
return enc
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *run) newCacheFs(t *testing.T, remote, id string, needRemote, purge bool, cfg map[string]string, flags map[string]string) (fs.Fs, *cache.Persistent) {
|
func (r *run) newCacheFs(t *testing.T, remote, id string, needRemote, purge bool, flags map[string]string) (fs.Fs, *cache.Persistent) {
|
||||||
fstest.Initialise()
|
fstest.Initialise()
|
||||||
remoteExists := false
|
remoteExists := false
|
||||||
for _, s := range config.FileSections() {
|
for _, s := range config.FileSections() {
|
||||||
|
@ -958,10 +940,15 @@ func (r *run) newCacheFs(t *testing.T, remote, id string, needRemote, purge bool
|
||||||
}
|
}
|
||||||
err = f.Mkdir(context.Background(), "")
|
err = f.Mkdir(context.Background(), "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
t.Cleanup(func() {
|
||||||
|
runInstance.cleanupFs(t, f)
|
||||||
|
})
|
||||||
|
|
||||||
return f, boltDb
|
return f, boltDb
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *run) cleanupFs(t *testing.T, f fs.Fs, b *cache.Persistent) {
|
func (r *run) cleanupFs(t *testing.T, f fs.Fs) {
|
||||||
err := f.Features().Purge(context.Background(), "")
|
err := f.Features().Purge(context.Background(), "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cfs, err := r.getCacheFs(f)
|
cfs, err := r.getCacheFs(f)
|
||||||
|
|
24
backend/cache/cache_upload_test.go
vendored
24
backend/cache/cache_upload_test.go
vendored
|
@ -21,10 +21,8 @@ import (
|
||||||
|
|
||||||
func TestInternalUploadTempDirCreated(t *testing.T) {
|
func TestInternalUploadTempDirCreated(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiutdc%v", time.Now().Unix())
|
id := fmt.Sprintf("tiutdc%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true,
|
runInstance.newCacheFs(t, remoteName, id, false, true,
|
||||||
nil,
|
|
||||||
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id)})
|
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id)})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
_, err := os.Stat(path.Join(runInstance.tmpUploadDir, id))
|
_, err := os.Stat(path.Join(runInstance.tmpUploadDir, id))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -63,9 +61,7 @@ func testInternalUploadQueueOneFile(t *testing.T, id string, rootFs fs.Fs, boltD
|
||||||
func TestInternalUploadQueueOneFileNoRest(t *testing.T) {
|
func TestInternalUploadQueueOneFileNoRest(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiuqofnr%v", time.Now().Unix())
|
id := fmt.Sprintf("tiuqofnr%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
||||||
nil,
|
|
||||||
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "0s"})
|
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "0s"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
testInternalUploadQueueOneFile(t, id, rootFs, boltDb)
|
testInternalUploadQueueOneFile(t, id, rootFs, boltDb)
|
||||||
}
|
}
|
||||||
|
@ -73,19 +69,15 @@ func TestInternalUploadQueueOneFileNoRest(t *testing.T) {
|
||||||
func TestInternalUploadQueueOneFileWithRest(t *testing.T) {
|
func TestInternalUploadQueueOneFileWithRest(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiuqofwr%v", time.Now().Unix())
|
id := fmt.Sprintf("tiuqofwr%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
||||||
nil,
|
|
||||||
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1m"})
|
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1m"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
testInternalUploadQueueOneFile(t, id, rootFs, boltDb)
|
testInternalUploadQueueOneFile(t, id, rootFs, boltDb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInternalUploadMoveExistingFile(t *testing.T) {
|
func TestInternalUploadMoveExistingFile(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiumef%v", time.Now().Unix())
|
id := fmt.Sprintf("tiumef%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true,
|
||||||
nil,
|
|
||||||
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "3s"})
|
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "3s"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
err := rootFs.Mkdir(context.Background(), "one")
|
err := rootFs.Mkdir(context.Background(), "one")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -119,10 +111,8 @@ func TestInternalUploadMoveExistingFile(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalUploadTempPathCleaned(t *testing.T) {
|
func TestInternalUploadTempPathCleaned(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiutpc%v", time.Now().Unix())
|
id := fmt.Sprintf("tiutpc%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true,
|
||||||
nil,
|
|
||||||
map[string]string{"cache-tmp-upload-path": path.Join(runInstance.tmpUploadDir, id), "cache-tmp-wait-time": "5s"})
|
map[string]string{"cache-tmp-upload-path": path.Join(runInstance.tmpUploadDir, id), "cache-tmp-wait-time": "5s"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
err := rootFs.Mkdir(context.Background(), "one")
|
err := rootFs.Mkdir(context.Background(), "one")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -162,10 +152,8 @@ func TestInternalUploadTempPathCleaned(t *testing.T) {
|
||||||
|
|
||||||
func TestInternalUploadQueueMoreFiles(t *testing.T) {
|
func TestInternalUploadQueueMoreFiles(t *testing.T) {
|
||||||
id := fmt.Sprintf("tiuqmf%v", time.Now().Unix())
|
id := fmt.Sprintf("tiuqmf%v", time.Now().Unix())
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true,
|
||||||
nil,
|
|
||||||
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1s"})
|
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1s"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
err := rootFs.Mkdir(context.Background(), "test")
|
err := rootFs.Mkdir(context.Background(), "test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -213,9 +201,7 @@ func TestInternalUploadQueueMoreFiles(t *testing.T) {
|
||||||
func TestInternalUploadTempFileOperations(t *testing.T) {
|
func TestInternalUploadTempFileOperations(t *testing.T) {
|
||||||
id := "tiutfo"
|
id := "tiutfo"
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
||||||
nil,
|
|
||||||
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1h"})
|
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1h"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
boltDb.PurgeTempUploads()
|
boltDb.PurgeTempUploads()
|
||||||
|
|
||||||
|
@ -343,9 +329,7 @@ func TestInternalUploadTempFileOperations(t *testing.T) {
|
||||||
func TestInternalUploadUploadingFileOperations(t *testing.T) {
|
func TestInternalUploadUploadingFileOperations(t *testing.T) {
|
||||||
id := "tiuufo"
|
id := "tiuufo"
|
||||||
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true,
|
||||||
nil,
|
|
||||||
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1h"})
|
map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1h"})
|
||||||
defer runInstance.cleanupFs(t, rootFs, boltDb)
|
|
||||||
|
|
||||||
boltDb.PurgeTempUploads()
|
boltDb.PurgeTempUploads()
|
||||||
|
|
||||||
|
|
|
@ -19,26 +19,26 @@ import (
|
||||||
|
|
||||||
// Create a temporary local fs to upload things from
|
// Create a temporary local fs to upload things from
|
||||||
|
|
||||||
func makeTempLocalFs(t *testing.T) (localFs fs.Fs, cleanup func()) {
|
func makeTempLocalFs(t *testing.T) (localFs fs.Fs) {
|
||||||
localFs, err := fs.TemporaryLocalFs(context.Background())
|
localFs, err := fs.TemporaryLocalFs(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup = func() {
|
t.Cleanup(func() {
|
||||||
require.NoError(t, localFs.Rmdir(context.Background(), ""))
|
require.NoError(t, localFs.Rmdir(context.Background(), ""))
|
||||||
}
|
})
|
||||||
return localFs, cleanup
|
return localFs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload a file to a remote
|
// Upload a file to a remote
|
||||||
func uploadFile(t *testing.T, f fs.Fs, remote, contents string) (obj fs.Object, cleanup func()) {
|
func uploadFile(t *testing.T, f fs.Fs, remote, contents string) (obj fs.Object) {
|
||||||
inBuf := bytes.NewBufferString(contents)
|
inBuf := bytes.NewBufferString(contents)
|
||||||
t1 := time.Date(2012, time.December, 17, 18, 32, 31, 0, time.UTC)
|
t1 := time.Date(2012, time.December, 17, 18, 32, 31, 0, time.UTC)
|
||||||
upSrc := object.NewStaticObjectInfo(remote, t1, int64(len(contents)), true, nil, nil)
|
upSrc := object.NewStaticObjectInfo(remote, t1, int64(len(contents)), true, nil, nil)
|
||||||
obj, err := f.Put(context.Background(), inBuf, upSrc)
|
obj, err := f.Put(context.Background(), inBuf, upSrc)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup = func() {
|
t.Cleanup(func() {
|
||||||
require.NoError(t, obj.Remove(context.Background()))
|
require.NoError(t, obj.Remove(context.Background()))
|
||||||
}
|
})
|
||||||
return obj, cleanup
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the ObjectInfo
|
// Test the ObjectInfo
|
||||||
|
@ -52,11 +52,9 @@ func testObjectInfo(t *testing.T, f *Fs, wrap bool) {
|
||||||
path = "_wrap"
|
path = "_wrap"
|
||||||
}
|
}
|
||||||
|
|
||||||
localFs, cleanupLocalFs := makeTempLocalFs(t)
|
localFs := makeTempLocalFs(t)
|
||||||
defer cleanupLocalFs()
|
|
||||||
|
|
||||||
obj, cleanupObj := uploadFile(t, localFs, path, contents)
|
obj := uploadFile(t, localFs, path, contents)
|
||||||
defer cleanupObj()
|
|
||||||
|
|
||||||
// encrypt the data
|
// encrypt the data
|
||||||
inBuf := bytes.NewBufferString(contents)
|
inBuf := bytes.NewBufferString(contents)
|
||||||
|
@ -103,16 +101,13 @@ func testComputeHash(t *testing.T, f *Fs) {
|
||||||
t.Skipf("%v: does not support hashes", f.Fs)
|
t.Skipf("%v: does not support hashes", f.Fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
localFs, cleanupLocalFs := makeTempLocalFs(t)
|
localFs := makeTempLocalFs(t)
|
||||||
defer cleanupLocalFs()
|
|
||||||
|
|
||||||
// Upload a file to localFs as a test object
|
// Upload a file to localFs as a test object
|
||||||
localObj, cleanupLocalObj := uploadFile(t, localFs, path, contents)
|
localObj := uploadFile(t, localFs, path, contents)
|
||||||
defer cleanupLocalObj()
|
|
||||||
|
|
||||||
// Upload the same data to the remote Fs also
|
// Upload the same data to the remote Fs also
|
||||||
remoteObj, cleanupRemoteObj := uploadFile(t, f, path, contents)
|
remoteObj := uploadFile(t, f, path, contents)
|
||||||
defer cleanupRemoteObj()
|
|
||||||
|
|
||||||
// Calculate the expected Hash of the remote object
|
// Calculate the expected Hash of the remote object
|
||||||
computedHash, err := f.ComputeHash(ctx, remoteObj.(*Object), localObj, hashType)
|
computedHash, err := f.ComputeHash(ctx, remoteObj.(*Object), localObj, hashType)
|
||||||
|
|
|
@ -33,8 +33,9 @@ var (
|
||||||
lineEndSize = 1
|
lineEndSize = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// prepareServer the test server and return a function to tidy it up afterwards
|
// prepareServer prepares the test server and shuts it down automatically
|
||||||
func prepareServer(t *testing.T) (configmap.Simple, func()) {
|
// when the test completes.
|
||||||
|
func prepareServer(t *testing.T) configmap.Simple {
|
||||||
// file server for test/files
|
// file server for test/files
|
||||||
fileServer := http.FileServer(http.Dir(filesPath))
|
fileServer := http.FileServer(http.Dir(filesPath))
|
||||||
|
|
||||||
|
@ -78,20 +79,21 @@ func prepareServer(t *testing.T) (configmap.Simple, func()) {
|
||||||
"url": ts.URL,
|
"url": ts.URL,
|
||||||
"headers": strings.Join(headers, ","),
|
"headers": strings.Join(headers, ","),
|
||||||
}
|
}
|
||||||
|
t.Cleanup(ts.Close)
|
||||||
|
|
||||||
// return a function to tidy up
|
return m
|
||||||
return m, ts.Close
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare the test server and return a function to tidy it up afterwards
|
// prepare prepares the test server and shuts it down automatically
|
||||||
func prepare(t *testing.T) (fs.Fs, func()) {
|
// when the test completes.
|
||||||
m, tidy := prepareServer(t)
|
func prepare(t *testing.T) fs.Fs {
|
||||||
|
m := prepareServer(t)
|
||||||
|
|
||||||
// Instantiate it
|
// Instantiate it
|
||||||
f, err := NewFs(context.Background(), remoteName, "", m)
|
f, err := NewFs(context.Background(), remoteName, "", m)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return f, tidy
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func testListRoot(t *testing.T, f fs.Fs, noSlash bool) {
|
func testListRoot(t *testing.T, f fs.Fs, noSlash bool) {
|
||||||
|
@ -134,22 +136,19 @@ func testListRoot(t *testing.T, f fs.Fs, noSlash bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListRoot(t *testing.T) {
|
func TestListRoot(t *testing.T) {
|
||||||
f, tidy := prepare(t)
|
f := prepare(t)
|
||||||
defer tidy()
|
|
||||||
testListRoot(t, f, false)
|
testListRoot(t, f, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListRootNoSlash(t *testing.T) {
|
func TestListRootNoSlash(t *testing.T) {
|
||||||
f, tidy := prepare(t)
|
f := prepare(t)
|
||||||
f.(*Fs).opt.NoSlash = true
|
f.(*Fs).opt.NoSlash = true
|
||||||
defer tidy()
|
|
||||||
|
|
||||||
testListRoot(t, f, true)
|
testListRoot(t, f, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListSubDir(t *testing.T) {
|
func TestListSubDir(t *testing.T) {
|
||||||
f, tidy := prepare(t)
|
f := prepare(t)
|
||||||
defer tidy()
|
|
||||||
|
|
||||||
entries, err := f.List(context.Background(), "three")
|
entries, err := f.List(context.Background(), "three")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -166,8 +165,7 @@ func TestListSubDir(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewObject(t *testing.T) {
|
func TestNewObject(t *testing.T) {
|
||||||
f, tidy := prepare(t)
|
f := prepare(t)
|
||||||
defer tidy()
|
|
||||||
|
|
||||||
o, err := f.NewObject(context.Background(), "four/under four.txt")
|
o, err := f.NewObject(context.Background(), "four/under four.txt")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -194,8 +192,7 @@ func TestNewObject(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOpen(t *testing.T) {
|
func TestOpen(t *testing.T) {
|
||||||
m, tidy := prepareServer(t)
|
m := prepareServer(t)
|
||||||
defer tidy()
|
|
||||||
|
|
||||||
for _, head := range []bool{false, true} {
|
for _, head := range []bool{false, true} {
|
||||||
if !head {
|
if !head {
|
||||||
|
@ -257,8 +254,7 @@ func TestOpen(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMimeType(t *testing.T) {
|
func TestMimeType(t *testing.T) {
|
||||||
f, tidy := prepare(t)
|
f := prepare(t)
|
||||||
defer tidy()
|
|
||||||
|
|
||||||
o, err := f.NewObject(context.Background(), "four/under four.txt")
|
o, err := f.NewObject(context.Background(), "four/under four.txt")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -269,8 +265,7 @@ func TestMimeType(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsAFileRoot(t *testing.T) {
|
func TestIsAFileRoot(t *testing.T) {
|
||||||
m, tidy := prepareServer(t)
|
m := prepareServer(t)
|
||||||
defer tidy()
|
|
||||||
|
|
||||||
f, err := NewFs(context.Background(), remoteName, "one%.txt", m)
|
f, err := NewFs(context.Background(), remoteName, "one%.txt", m)
|
||||||
assert.Equal(t, err, fs.ErrorIsFile)
|
assert.Equal(t, err, fs.ErrorIsFile)
|
||||||
|
@ -279,8 +274,7 @@ func TestIsAFileRoot(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsAFileSubDir(t *testing.T) {
|
func TestIsAFileSubDir(t *testing.T) {
|
||||||
m, tidy := prepareServer(t)
|
m := prepareServer(t)
|
||||||
defer tidy()
|
|
||||||
|
|
||||||
f, err := NewFs(context.Background(), remoteName, "three/underthree.txt", m)
|
f, err := NewFs(context.Background(), remoteName, "three/underthree.txt", m)
|
||||||
assert.Equal(t, err, fs.ErrorIsFile)
|
assert.Equal(t, err, fs.ErrorIsFile)
|
||||||
|
|
|
@ -33,7 +33,6 @@ func TestMain(m *testing.M) {
|
||||||
// Test copy with source file that's updating
|
// Test copy with source file that's updating
|
||||||
func TestUpdatingCheck(t *testing.T) {
|
func TestUpdatingCheck(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
filePath := "sub dir/local test"
|
filePath := "sub dir/local test"
|
||||||
r.WriteFile(filePath, "content", time.Now())
|
r.WriteFile(filePath, "content", time.Now())
|
||||||
|
|
||||||
|
@ -78,7 +77,6 @@ func TestUpdatingCheck(t *testing.T) {
|
||||||
func TestSymlink(t *testing.T) {
|
func TestSymlink(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
f := r.Flocal.(*Fs)
|
f := r.Flocal.(*Fs)
|
||||||
dir := f.root
|
dir := f.root
|
||||||
|
|
||||||
|
@ -177,7 +175,6 @@ func TestSymlinkError(t *testing.T) {
|
||||||
func TestHashOnUpdate(t *testing.T) {
|
func TestHashOnUpdate(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
const filePath = "file.txt"
|
const filePath = "file.txt"
|
||||||
when := time.Now()
|
when := time.Now()
|
||||||
r.WriteFile(filePath, "content", when)
|
r.WriteFile(filePath, "content", when)
|
||||||
|
@ -208,7 +205,6 @@ func TestHashOnUpdate(t *testing.T) {
|
||||||
func TestHashOnDelete(t *testing.T) {
|
func TestHashOnDelete(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
const filePath = "file.txt"
|
const filePath = "file.txt"
|
||||||
when := time.Now()
|
when := time.Now()
|
||||||
r.WriteFile(filePath, "content", when)
|
r.WriteFile(filePath, "content", when)
|
||||||
|
@ -237,7 +233,6 @@ func TestHashOnDelete(t *testing.T) {
|
||||||
func TestMetadata(t *testing.T) {
|
func TestMetadata(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
const filePath = "metafile.txt"
|
const filePath = "metafile.txt"
|
||||||
when := time.Now()
|
when := time.Now()
|
||||||
const dayLength = len("2001-01-01")
|
const dayLength = len("2001-01-01")
|
||||||
|
@ -372,7 +367,6 @@ func TestMetadata(t *testing.T) {
|
||||||
func TestFilter(t *testing.T) {
|
func TestFilter(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
when := time.Now()
|
when := time.Now()
|
||||||
r.WriteFile("included", "included file", when)
|
r.WriteFile("included", "included file", when)
|
||||||
r.WriteFile("excluded", "excluded file", when)
|
r.WriteFile("excluded", "excluded file", when)
|
||||||
|
|
|
@ -15,8 +15,6 @@ import (
|
||||||
|
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fstest/testy"
|
"github.com/rclone/rclone/fstest/testy"
|
||||||
"github.com/rclone/rclone/lib/file"
|
|
||||||
"github.com/rclone/rclone/lib/random"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,20 +44,6 @@ func TestGetVersion(t *testing.T) {
|
||||||
assert.Equal(t, "v1.52.3", resultVer)
|
assert.Equal(t, "v1.52.3", resultVer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeTestDir() (testDir string, err error) {
|
|
||||||
const maxAttempts = 5
|
|
||||||
testDirBase := filepath.Join(os.TempDir(), "rclone-test-selfupdate.")
|
|
||||||
|
|
||||||
for attempt := 0; attempt < maxAttempts; attempt++ {
|
|
||||||
testDir = testDirBase + random.String(4)
|
|
||||||
err = file.MkdirAll(testDir, os.ModePerm)
|
|
||||||
if err == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestInstallOnLinux(t *testing.T) {
|
func TestInstallOnLinux(t *testing.T) {
|
||||||
testy.SkipUnreliable(t)
|
testy.SkipUnreliable(t)
|
||||||
if runtime.GOOS != "linux" {
|
if runtime.GOOS != "linux" {
|
||||||
|
@ -68,13 +52,8 @@ func TestInstallOnLinux(t *testing.T) {
|
||||||
|
|
||||||
// Prepare for test
|
// Prepare for test
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
testDir, err := makeTestDir()
|
testDir := t.TempDir()
|
||||||
assert.NoError(t, err)
|
|
||||||
path := filepath.Join(testDir, "rclone")
|
path := filepath.Join(testDir, "rclone")
|
||||||
defer func() {
|
|
||||||
_ = os.Chmod(path, 0644)
|
|
||||||
_ = os.RemoveAll(testDir)
|
|
||||||
}()
|
|
||||||
|
|
||||||
regexVer := regexp.MustCompile(`v[0-9]\S+`)
|
regexVer := regexp.MustCompile(`v[0-9]\S+`)
|
||||||
|
|
||||||
|
@ -87,6 +66,9 @@ func TestInstallOnLinux(t *testing.T) {
|
||||||
// Must fail on non-writable file
|
// Must fail on non-writable file
|
||||||
assert.NoError(t, os.WriteFile(path, []byte("test"), 0644))
|
assert.NoError(t, os.WriteFile(path, []byte("test"), 0644))
|
||||||
assert.NoError(t, os.Chmod(path, 0000))
|
assert.NoError(t, os.Chmod(path, 0000))
|
||||||
|
defer func() {
|
||||||
|
_ = os.Chmod(path, 0644)
|
||||||
|
}()
|
||||||
err = (InstallUpdate(ctx, &Options{Beta: true, Output: path}))
|
err = (InstallUpdate(ctx, &Options{Beta: true, Output: path}))
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.Error(), "run self-update as root")
|
assert.Contains(t, err.Error(), "run self-update as root")
|
||||||
|
@ -122,11 +104,7 @@ func TestRenameOnWindows(t *testing.T) {
|
||||||
// Prepare for test
|
// Prepare for test
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
testDir, err := makeTestDir()
|
testDir := t.TempDir()
|
||||||
assert.NoError(t, err)
|
|
||||||
defer func() {
|
|
||||||
_ = os.RemoveAll(testDir)
|
|
||||||
}()
|
|
||||||
|
|
||||||
path := filepath.Join(testDir, "rclone.exe")
|
path := filepath.Join(testDir, "rclone.exe")
|
||||||
regexVer := regexp.MustCompile(`v[0-9]\S+`)
|
regexVer := regexp.MustCompile(`v[0-9]\S+`)
|
||||||
|
|
|
@ -28,7 +28,6 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
func TestTouchOneFile(t *testing.T) {
|
func TestTouchOneFile(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
err := Touch(context.Background(), r.Fremote, "newFile")
|
err := Touch(context.Background(), r.Fremote, "newFile")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -38,7 +37,6 @@ func TestTouchOneFile(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchWithNoCreateFlag(t *testing.T) {
|
func TestTouchWithNoCreateFlag(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
notCreateNewFile = true
|
notCreateNewFile = true
|
||||||
err := Touch(context.Background(), r.Fremote, "newFile")
|
err := Touch(context.Background(), r.Fremote, "newFile")
|
||||||
|
@ -50,7 +48,6 @@ func TestTouchWithNoCreateFlag(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchWithTimestamp(t *testing.T) {
|
func TestTouchWithTimestamp(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
timeAsArgument = "060102"
|
timeAsArgument = "060102"
|
||||||
srcFileName := "oldFile"
|
srcFileName := "oldFile"
|
||||||
|
@ -61,7 +58,6 @@ func TestTouchWithTimestamp(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchWithLongerTimestamp(t *testing.T) {
|
func TestTouchWithLongerTimestamp(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
timeAsArgument = "2006-01-02T15:04:05"
|
timeAsArgument = "2006-01-02T15:04:05"
|
||||||
srcFileName := "oldFile"
|
srcFileName := "oldFile"
|
||||||
|
@ -72,7 +68,6 @@ func TestTouchWithLongerTimestamp(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchUpdateTimestamp(t *testing.T) {
|
func TestTouchUpdateTimestamp(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
srcFileName := "a"
|
srcFileName := "a"
|
||||||
content := "aaa"
|
content := "aaa"
|
||||||
|
@ -87,7 +82,6 @@ func TestTouchUpdateTimestamp(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchUpdateTimestampWithCFlag(t *testing.T) {
|
func TestTouchUpdateTimestampWithCFlag(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
srcFileName := "a"
|
srcFileName := "a"
|
||||||
content := "aaa"
|
content := "aaa"
|
||||||
|
@ -104,7 +98,6 @@ func TestTouchUpdateTimestampWithCFlag(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchCreateMultipleDirAndFile(t *testing.T) {
|
func TestTouchCreateMultipleDirAndFile(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
longPath := "a/b/c.txt"
|
longPath := "a/b/c.txt"
|
||||||
err := Touch(context.Background(), r.Fremote, longPath)
|
err := Touch(context.Background(), r.Fremote, longPath)
|
||||||
|
@ -115,7 +108,6 @@ func TestTouchCreateMultipleDirAndFile(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchEmptyName(t *testing.T) {
|
func TestTouchEmptyName(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
err := Touch(context.Background(), r.Fremote, "")
|
err := Touch(context.Background(), r.Fremote, "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -124,7 +116,6 @@ func TestTouchEmptyName(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchEmptyDir(t *testing.T) {
|
func TestTouchEmptyDir(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
err := r.Fremote.Mkdir(context.Background(), "a")
|
err := r.Fremote.Mkdir(context.Background(), "a")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -135,7 +126,6 @@ func TestTouchEmptyDir(t *testing.T) {
|
||||||
|
|
||||||
func TestTouchDirWithFiles(t *testing.T) {
|
func TestTouchDirWithFiles(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
err := r.Fremote.Mkdir(context.Background(), "a")
|
err := r.Fremote.Mkdir(context.Background(), "a")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -148,7 +138,6 @@ func TestTouchDirWithFiles(t *testing.T) {
|
||||||
|
|
||||||
func TestRecursiveTouchDirWithFiles(t *testing.T) {
|
func TestRecursiveTouchDirWithFiles(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
err := r.Fremote.Mkdir(context.Background(), "a/b/c")
|
err := r.Fremote.Mkdir(context.Background(), "a/b/c")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -111,13 +111,6 @@ func createTestEnvironment(t *testing.T) {
|
||||||
var testFolder string
|
var testFolder string
|
||||||
var testConfig string
|
var testConfig string
|
||||||
|
|
||||||
// removeTestEnvironment removes the test environment created by createTestEnvironment
|
|
||||||
func removeTestEnvironment(t *testing.T) {
|
|
||||||
// Remove temporary folder with all contents
|
|
||||||
err := os.RemoveAll(testFolder)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// createTestFile creates the file testFolder/name
|
// createTestFile creates the file testFolder/name
|
||||||
func createTestFile(name string, t *testing.T) string {
|
func createTestFile(name string, t *testing.T) string {
|
||||||
err := os.WriteFile(testFolder+"/"+name, []byte("content_of_"+name), 0666)
|
err := os.WriteFile(testFolder+"/"+name, []byte("content_of_"+name), 0666)
|
||||||
|
@ -146,19 +139,18 @@ func createSimpleTestData(t *testing.T) string {
|
||||||
createTestFolder("testdata/folderB", t)
|
createTestFolder("testdata/folderB", t)
|
||||||
createTestFile("testdata/folderB/fileB1.txt", t)
|
createTestFile("testdata/folderB/fileB1.txt", t)
|
||||||
createTestFile("testdata/folderB/fileB2.txt", t)
|
createTestFile("testdata/folderB/fileB2.txt", t)
|
||||||
return testFolder + "/testdata"
|
|
||||||
}
|
|
||||||
|
|
||||||
// removeSimpleTestData removes the test data created by createSimpleTestData
|
t.Cleanup(func() {
|
||||||
func removeSimpleTestData(t *testing.T) {
|
err := os.RemoveAll(testFolder + "/testdata")
|
||||||
err := os.RemoveAll(testFolder + "/testdata")
|
require.NoError(t, err)
|
||||||
require.NoError(t, err)
|
})
|
||||||
|
|
||||||
|
return testFolder + "/testdata"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCmdTest demonstrates and verifies the test functions for end-to-end testing of rclone
|
// TestCmdTest demonstrates and verifies the test functions for end-to-end testing of rclone
|
||||||
func TestCmdTest(t *testing.T) {
|
func TestCmdTest(t *testing.T) {
|
||||||
createTestEnvironment(t)
|
createTestEnvironment(t)
|
||||||
defer removeTestEnvironment(t)
|
|
||||||
|
|
||||||
// Test simple call and output from rclone
|
// Test simple call and output from rclone
|
||||||
out, err := rclone("version")
|
out, err := rclone("version")
|
||||||
|
@ -213,7 +205,6 @@ func TestCmdTest(t *testing.T) {
|
||||||
|
|
||||||
// Test creation of simple test data
|
// Test creation of simple test data
|
||||||
createSimpleTestData(t)
|
createSimpleTestData(t)
|
||||||
defer removeSimpleTestData(t)
|
|
||||||
|
|
||||||
// Test access to config file and simple test data
|
// Test access to config file and simple test data
|
||||||
out, err = rclone("lsl", "myLocal:"+testFolder)
|
out, err = rclone("lsl", "myLocal:"+testFolder)
|
||||||
|
|
|
@ -17,10 +17,8 @@ import (
|
||||||
func TestEnvironmentVariables(t *testing.T) {
|
func TestEnvironmentVariables(t *testing.T) {
|
||||||
|
|
||||||
createTestEnvironment(t)
|
createTestEnvironment(t)
|
||||||
defer removeTestEnvironment(t)
|
|
||||||
|
|
||||||
testdataPath := createSimpleTestData(t)
|
testdataPath := createSimpleTestData(t)
|
||||||
defer removeSimpleTestData(t)
|
|
||||||
|
|
||||||
// Non backend flags
|
// Non backend flags
|
||||||
// =================
|
// =================
|
||||||
|
|
35
fs/cache/cache_test.go
vendored
35
fs/cache/cache_test.go
vendored
|
@ -16,7 +16,7 @@ var (
|
||||||
errSentinel = errors.New("an error")
|
errSentinel = errors.New("an error")
|
||||||
)
|
)
|
||||||
|
|
||||||
func mockNewFs(t *testing.T) (func(), func(ctx context.Context, path string) (fs.Fs, error)) {
|
func mockNewFs(t *testing.T) func(ctx context.Context, path string) (fs.Fs, error) {
|
||||||
called = 0
|
called = 0
|
||||||
create := func(ctx context.Context, path string) (f fs.Fs, err error) {
|
create := func(ctx context.Context, path string) (f fs.Fs, err error) {
|
||||||
assert.Equal(t, 0, called)
|
assert.Equal(t, 0, called)
|
||||||
|
@ -32,15 +32,12 @@ func mockNewFs(t *testing.T) (func(), func(ctx context.Context, path string) (fs
|
||||||
t.Fatalf("Unknown path %q", path)
|
t.Fatalf("Unknown path %q", path)
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
cleanup := func() {
|
t.Cleanup(Clear)
|
||||||
Clear()
|
return create
|
||||||
}
|
|
||||||
return cleanup, create
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, 0, Entries())
|
assert.Equal(t, 0, Entries())
|
||||||
|
|
||||||
|
@ -56,8 +53,7 @@ func TestGet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFile(t *testing.T) {
|
func TestGetFile(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, 0, Entries())
|
assert.Equal(t, 0, Entries())
|
||||||
|
|
||||||
|
@ -82,8 +78,7 @@ func TestGetFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFile2(t *testing.T) {
|
func TestGetFile2(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, 0, Entries())
|
assert.Equal(t, 0, Entries())
|
||||||
|
|
||||||
|
@ -108,8 +103,7 @@ func TestGetFile2(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetError(t *testing.T) {
|
func TestGetError(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, 0, Entries())
|
assert.Equal(t, 0, Entries())
|
||||||
|
|
||||||
|
@ -121,8 +115,7 @@ func TestGetError(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPut(t *testing.T) {
|
func TestPut(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
f := mockfs.NewFs(context.Background(), "mock", "/alien")
|
f := mockfs.NewFs(context.Background(), "mock", "/alien")
|
||||||
|
|
||||||
|
@ -151,8 +144,7 @@ func TestPut(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPin(t *testing.T) {
|
func TestPin(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Test pinning and unpinning nonexistent
|
// Test pinning and unpinning nonexistent
|
||||||
f := mockfs.NewFs(context.Background(), "mock", "/alien")
|
f := mockfs.NewFs(context.Background(), "mock", "/alien")
|
||||||
|
@ -167,8 +159,7 @@ func TestPin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClearConfig(t *testing.T) {
|
func TestClearConfig(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, 0, Entries())
|
assert.Equal(t, 0, Entries())
|
||||||
|
|
||||||
|
@ -183,8 +174,7 @@ func TestClearConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClear(t *testing.T) {
|
func TestClear(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Create something
|
// Create something
|
||||||
_, err := GetFn(context.Background(), "mock:/", create)
|
_, err := GetFn(context.Background(), "mock:/", create)
|
||||||
|
@ -198,8 +188,7 @@ func TestClear(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEntries(t *testing.T) {
|
func TestEntries(t *testing.T) {
|
||||||
cleanup, create := mockNewFs(t)
|
create := mockNewFs(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, 0, Entries())
|
assert.Equal(t, 0, Entries())
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,6 @@ func TestMarch(t *testing.T) {
|
||||||
} {
|
} {
|
||||||
t.Run(fmt.Sprintf("TestMarch-%s", test.what), func(t *testing.T) {
|
t.Run(fmt.Sprintf("TestMarch-%s", test.what), func(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
var srcOnly []fstest.Item
|
var srcOnly []fstest.Item
|
||||||
var dstOnly []fstest.Item
|
var dstOnly []fstest.Item
|
||||||
|
@ -242,7 +241,6 @@ func TestMarchNoTraverse(t *testing.T) {
|
||||||
} {
|
} {
|
||||||
t.Run(fmt.Sprintf("TestMarch-%s", test.what), func(t *testing.T) {
|
t.Run(fmt.Sprintf("TestMarch-%s", test.what), func(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
var srcOnly []fstest.Item
|
var srcOnly []fstest.Item
|
||||||
var match []fstest.Item
|
var match []fstest.Item
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
|
|
||||||
func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operations.CheckOpt) error) {
|
func testCheck(t *testing.T, checkFunction func(ctx context.Context, opt *operations.CheckOpt) error) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ci := fs.GetConfig(ctx)
|
ci := fs.GetConfig(ctx)
|
||||||
|
|
||||||
|
@ -279,7 +278,6 @@ func TestCheckEqualReaders(t *testing.T) {
|
||||||
|
|
||||||
func TestParseSumFile(t *testing.T) {
|
func TestParseSumFile(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
const sumFile = "test.sum"
|
const sumFile = "test.sum"
|
||||||
|
@ -342,7 +340,6 @@ func testCheckSum(t *testing.T, download bool) {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
subRemote := r.FremoteName
|
subRemote := r.FremoteName
|
||||||
if !strings.HasSuffix(subRemote, ":") {
|
if !strings.HasSuffix(subRemote, ":") {
|
||||||
|
|
|
@ -45,7 +45,6 @@ func skipIfNoModTime(t *testing.T, f fs.Fs) {
|
||||||
|
|
||||||
func TestDeduplicateInteractive(t *testing.T) {
|
func TestDeduplicateInteractive(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
skipIfNoHash(t, r.Fremote)
|
skipIfNoHash(t, r.Fremote)
|
||||||
|
|
||||||
|
@ -62,7 +61,6 @@ func TestDeduplicateInteractive(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateSkip(t *testing.T) {
|
func TestDeduplicateSkip(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
haveHash := r.Fremote.Hashes().GetOne() != hash.None
|
haveHash := r.Fremote.Hashes().GetOne() != hash.None
|
||||||
|
|
||||||
|
@ -84,7 +82,6 @@ func TestDeduplicateSkip(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateSizeOnly(t *testing.T) {
|
func TestDeduplicateSizeOnly(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ci := fs.GetConfig(ctx)
|
ci := fs.GetConfig(ctx)
|
||||||
|
@ -107,7 +104,6 @@ func TestDeduplicateSizeOnly(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateFirst(t *testing.T) {
|
func TestDeduplicateFirst(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
||||||
|
@ -136,7 +132,6 @@ func TestDeduplicateFirst(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateNewest(t *testing.T) {
|
func TestDeduplicateNewest(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
skipIfNoModTime(t, r.Fremote)
|
skipIfNoModTime(t, r.Fremote)
|
||||||
|
|
||||||
|
@ -153,7 +148,6 @@ func TestDeduplicateNewest(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateNewestByHash(t *testing.T) {
|
func TestDeduplicateNewestByHash(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfNoHash(t, r.Fremote)
|
skipIfNoHash(t, r.Fremote)
|
||||||
skipIfNoModTime(t, r.Fremote)
|
skipIfNoModTime(t, r.Fremote)
|
||||||
contents := random.String(100)
|
contents := random.String(100)
|
||||||
|
@ -172,7 +166,6 @@ func TestDeduplicateNewestByHash(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateOldest(t *testing.T) {
|
func TestDeduplicateOldest(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
||||||
|
@ -188,7 +181,6 @@ func TestDeduplicateOldest(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateLargest(t *testing.T) {
|
func TestDeduplicateLargest(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
||||||
|
@ -204,7 +196,6 @@ func TestDeduplicateLargest(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateSmallest(t *testing.T) {
|
func TestDeduplicateSmallest(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
file1 := r.WriteUncheckedObject(context.Background(), "one", "This is one", t1)
|
||||||
|
@ -220,7 +211,6 @@ func TestDeduplicateSmallest(t *testing.T) {
|
||||||
|
|
||||||
func TestDeduplicateRename(t *testing.T) {
|
func TestDeduplicateRename(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
skipIfCantDedupe(t, r.Fremote)
|
skipIfCantDedupe(t, r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteUncheckedObject(context.Background(), "one.txt", "This is one", t1)
|
file1 := r.WriteUncheckedObject(context.Background(), "one.txt", "This is one", t1)
|
||||||
|
@ -260,7 +250,6 @@ func TestDeduplicateRename(t *testing.T) {
|
||||||
// doesn't have enough tools to make it easy
|
// doesn't have enough tools to make it easy
|
||||||
func TestMergeDirs(t *testing.T) {
|
func TestMergeDirs(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
mergeDirs := r.Fremote.Features().MergeDirs
|
mergeDirs := r.Fremote.Features().MergeDirs
|
||||||
if mergeDirs == nil {
|
if mergeDirs == nil {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
// which can't be tested there due to import loops.
|
// which can't be tested there due to import loops.
|
||||||
func TestListDirSorted(t *testing.T) {
|
func TestListDirSorted(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
fi := filter.GetConfig(ctx)
|
fi := filter.GetConfig(ctx)
|
||||||
|
|
|
@ -37,7 +37,6 @@ func compareListJSONItem(t *testing.T, a, b *operations.ListJSONItem, precision
|
||||||
func TestListJSON(t *testing.T) {
|
func TestListJSON(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "file1", "file1", t1)
|
file1 := r.WriteBoth(ctx, "file1", "file1", t1)
|
||||||
file2 := r.WriteBoth(ctx, "sub/file2", "sub/file2", t2)
|
file2 := r.WriteBoth(ctx, "sub/file2", "sub/file2", t2)
|
||||||
|
|
||||||
|
@ -245,7 +244,6 @@ func TestListJSON(t *testing.T) {
|
||||||
func TestStatJSON(t *testing.T) {
|
func TestStatJSON(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "file1", "file1", t1)
|
file1 := r.WriteBoth(ctx, "file1", "file1", t1)
|
||||||
file2 := r.WriteBoth(ctx, "sub/file2", "sub/file2", t2)
|
file2 := r.WriteBoth(ctx, "sub/file2", "sub/file2", t2)
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,6 @@ func TestMultithreadCalculateChunks(t *testing.T) {
|
||||||
|
|
||||||
func TestMultithreadCopy(t *testing.T) {
|
func TestMultithreadCopy(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
|
|
|
@ -65,7 +65,6 @@ func TestMain(m *testing.M) {
|
||||||
func TestMkdir(t *testing.T) {
|
func TestMkdir(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
err := operations.Mkdir(ctx, r.Fremote, "")
|
err := operations.Mkdir(ctx, r.Fremote, "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -78,7 +77,6 @@ func TestMkdir(t *testing.T) {
|
||||||
func TestLsd(t *testing.T) {
|
func TestLsd(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
||||||
|
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
@ -93,7 +91,6 @@ func TestLsd(t *testing.T) {
|
||||||
func TestLs(t *testing.T) {
|
func TestLs(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
|
|
||||||
|
@ -111,7 +108,6 @@ func TestLsWithFilesFrom(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
|
|
||||||
|
@ -143,7 +139,6 @@ func TestLsWithFilesFrom(t *testing.T) {
|
||||||
func TestLsLong(t *testing.T) {
|
func TestLsLong(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
|
|
||||||
|
@ -186,7 +181,6 @@ func TestLsLong(t *testing.T) {
|
||||||
func TestHashSums(t *testing.T) {
|
func TestHashSums(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
|
|
||||||
|
@ -392,7 +386,6 @@ func TestCount(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
file3 := r.WriteBoth(ctx, "sub dir/potato3", "hello", t2)
|
file3 := r.WriteBoth(ctx, "sub dir/potato3", "hello", t2)
|
||||||
|
@ -416,7 +409,6 @@ func TestDelete(t *testing.T) {
|
||||||
fi.Opt.MaxSize = 60
|
fi.Opt.MaxSize = 60
|
||||||
ctx = filter.ReplaceConfig(ctx, fi)
|
ctx = filter.ReplaceConfig(ctx, fi)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(ctx, "small", "1234567890", t2) // 10 bytes
|
file1 := r.WriteObject(ctx, "small", "1234567890", t2) // 10 bytes
|
||||||
file2 := r.WriteObject(ctx, "medium", "------------------------------------------------------------", t1) // 60 bytes
|
file2 := r.WriteObject(ctx, "medium", "------------------------------------------------------------", t1) // 60 bytes
|
||||||
file3 := r.WriteObject(ctx, "large", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytes
|
file3 := r.WriteObject(ctx, "large", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytes
|
||||||
|
@ -457,7 +449,6 @@ func TestRetry(t *testing.T) {
|
||||||
func TestCat(t *testing.T) {
|
func TestCat(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "file1", "ABCDEFGHIJ", t1)
|
file1 := r.WriteBoth(ctx, "file1", "ABCDEFGHIJ", t1)
|
||||||
file2 := r.WriteBoth(ctx, "file2", "012345678", t2)
|
file2 := r.WriteBoth(ctx, "file2", "012345678", t2)
|
||||||
|
|
||||||
|
@ -488,7 +479,6 @@ func TestCat(t *testing.T) {
|
||||||
func TestPurge(t *testing.T) {
|
func TestPurge(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRunIndividual(t) // make new container (azureblob has delayed mkdir after rmdir)
|
r := fstest.NewRunIndividual(t) // make new container (azureblob has delayed mkdir after rmdir)
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
// Make some files and dirs
|
// Make some files and dirs
|
||||||
|
@ -561,7 +551,6 @@ func TestPurge(t *testing.T) {
|
||||||
func TestRmdirsNoLeaveRoot(t *testing.T) {
|
func TestRmdirsNoLeaveRoot(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
// Make some files and dirs we expect to keep
|
// Make some files and dirs we expect to keep
|
||||||
|
@ -642,7 +631,6 @@ func TestRmdirsNoLeaveRoot(t *testing.T) {
|
||||||
func TestRmdirsLeaveRoot(t *testing.T) {
|
func TestRmdirsLeaveRoot(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
r.ForceMkdir(ctx, r.Fremote)
|
r.ForceMkdir(ctx, r.Fremote)
|
||||||
|
@ -682,7 +670,6 @@ func TestRmdirsWithFilter(t *testing.T) {
|
||||||
require.NoError(t, fi.AddRule("+ /A1/B1/**"))
|
require.NoError(t, fi.AddRule("+ /A1/B1/**"))
|
||||||
require.NoError(t, fi.AddRule("- *"))
|
require.NoError(t, fi.AddRule("- *"))
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
r.ForceMkdir(ctx, r.Fremote)
|
r.ForceMkdir(ctx, r.Fremote)
|
||||||
|
@ -720,7 +707,6 @@ func TestCopyURL(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
contents := "file contents\n"
|
contents := "file contents\n"
|
||||||
file1 := r.WriteFile("file1", contents, t1)
|
file1 := r.WriteFile("file1", contents, t1)
|
||||||
|
@ -835,7 +821,6 @@ func TestCopyURLToWriter(t *testing.T) {
|
||||||
func TestMoveFile(t *testing.T) {
|
func TestMoveFile(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
file1 := r.WriteFile("file1", "file1 contents", t1)
|
file1 := r.WriteFile("file1", "file1 contents", t1)
|
||||||
r.CheckLocalItems(t, file1)
|
r.CheckLocalItems(t, file1)
|
||||||
|
@ -866,7 +851,6 @@ func TestMoveFileWithIgnoreExisting(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("file1", "file1 contents", t1)
|
file1 := r.WriteFile("file1", "file1 contents", t1)
|
||||||
r.CheckLocalItems(t, file1)
|
r.CheckLocalItems(t, file1)
|
||||||
|
|
||||||
|
@ -891,7 +875,6 @@ func TestMoveFileWithIgnoreExisting(t *testing.T) {
|
||||||
func TestCaseInsensitiveMoveFile(t *testing.T) {
|
func TestCaseInsensitiveMoveFile(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
if !r.Fremote.Features().CaseInsensitive {
|
if !r.Fremote.Features().CaseInsensitive {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -928,7 +911,6 @@ func TestMoveFileBackupDir(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
if !operations.CanServerSideMove(r.Fremote) {
|
if !operations.CanServerSideMove(r.Fremote) {
|
||||||
t.Skip("Skipping test as remote does not support server-side move or copy")
|
t.Skip("Skipping test as remote does not support server-side move or copy")
|
||||||
}
|
}
|
||||||
|
@ -951,7 +933,6 @@ func TestMoveFileBackupDir(t *testing.T) {
|
||||||
func TestCopyFile(t *testing.T) {
|
func TestCopyFile(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
file1 := r.WriteFile("file1", "file1 contents", t1)
|
file1 := r.WriteFile("file1", "file1 contents", t1)
|
||||||
r.CheckLocalItems(t, file1)
|
r.CheckLocalItems(t, file1)
|
||||||
|
@ -979,7 +960,6 @@ func TestCopyFileBackupDir(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
if !operations.CanServerSideMove(r.Fremote) {
|
if !operations.CanServerSideMove(r.Fremote) {
|
||||||
t.Skip("Skipping test as remote does not support server-side move or copy")
|
t.Skip("Skipping test as remote does not support server-side move or copy")
|
||||||
}
|
}
|
||||||
|
@ -1004,7 +984,6 @@ func TestCopyFileCompareDest(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.CompareDest = []string{r.FremoteName + "/CompareDest"}
|
ci.CompareDest = []string{r.FremoteName + "/CompareDest"}
|
||||||
fdst, err := fs.NewFs(ctx, r.FremoteName+"/dst")
|
fdst, err := fs.NewFs(ctx, r.FremoteName+"/dst")
|
||||||
|
@ -1083,7 +1062,6 @@ func TestCopyFileCopyDest(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if r.Fremote.Features().Copy == nil {
|
if r.Fremote.Features().Copy == nil {
|
||||||
t.Skip("Skipping test as remote does not support server-side copy")
|
t.Skip("Skipping test as remote does not support server-side copy")
|
||||||
|
@ -1457,7 +1435,6 @@ func TestListFormat(t *testing.T) {
|
||||||
func TestDirMove(t *testing.T) {
|
func TestDirMove(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
|
@ -1538,7 +1515,6 @@ func TestDirMove(t *testing.T) {
|
||||||
|
|
||||||
func TestGetFsInfo(t *testing.T) {
|
func TestGetFsInfo(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
f := r.Fremote
|
f := r.Fremote
|
||||||
info := operations.GetFsInfo(f)
|
info := operations.GetFsInfo(f)
|
||||||
|
@ -1559,7 +1535,7 @@ func TestGetFsInfo(t *testing.T) {
|
||||||
func TestRcat(t *testing.T) {
|
func TestRcat(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
check := func(withChecksum, ignoreChecksum bool) {
|
check := func(t *testing.T, withChecksum, ignoreChecksum bool) {
|
||||||
ci.CheckSum, ci.IgnoreChecksum = withChecksum, ignoreChecksum
|
ci.CheckSum, ci.IgnoreChecksum = withChecksum, ignoreChecksum
|
||||||
|
|
||||||
var prefix string
|
var prefix string
|
||||||
|
@ -1573,7 +1549,6 @@ func TestRcat(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if *fstest.SizeLimit > 0 && int64(ci.StreamingUploadCutoff) > *fstest.SizeLimit {
|
if *fstest.SizeLimit > 0 && int64(ci.StreamingUploadCutoff) > *fstest.SizeLimit {
|
||||||
savedCutoff := ci.StreamingUploadCutoff
|
savedCutoff := ci.StreamingUploadCutoff
|
||||||
|
@ -1606,14 +1581,13 @@ func TestRcat(t *testing.T) {
|
||||||
withChecksum := (i & 1) != 0
|
withChecksum := (i & 1) != 0
|
||||||
ignoreChecksum := (i & 2) != 0
|
ignoreChecksum := (i & 2) != 0
|
||||||
t.Run(fmt.Sprintf("withChecksum=%v,ignoreChecksum=%v", withChecksum, ignoreChecksum), func(t *testing.T) {
|
t.Run(fmt.Sprintf("withChecksum=%v,ignoreChecksum=%v", withChecksum, ignoreChecksum), func(t *testing.T) {
|
||||||
check(withChecksum, ignoreChecksum)
|
check(t, withChecksum, ignoreChecksum)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRcatMetadata(t *testing.T) {
|
func TestRcatMetadata(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if !r.Fremote.Features().UserMetadata {
|
if !r.Fremote.Features().UserMetadata {
|
||||||
t.Skip("Skipping as destination doesn't support user metadata")
|
t.Skip("Skipping as destination doesn't support user metadata")
|
||||||
|
@ -1670,7 +1644,6 @@ func TestRcatMetadata(t *testing.T) {
|
||||||
func TestRcatSize(t *testing.T) {
|
func TestRcatSize(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
const body = "------------------------------------------------------------"
|
const body = "------------------------------------------------------------"
|
||||||
file1 := r.WriteFile("potato1", body, t1)
|
file1 := r.WriteFile("potato1", body, t1)
|
||||||
|
@ -1696,7 +1669,6 @@ func TestRcatSize(t *testing.T) {
|
||||||
|
|
||||||
func TestRcatSizeMetadata(t *testing.T) {
|
func TestRcatSizeMetadata(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if !r.Fremote.Features().UserMetadata {
|
if !r.Fremote.Features().UserMetadata {
|
||||||
t.Skip("Skipping as destination doesn't support user metadata")
|
t.Skip("Skipping as destination doesn't support user metadata")
|
||||||
|
@ -1750,7 +1722,6 @@ func TestCopyFileMaxTransfer(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
defer accounting.Stats(ctx).ResetCounters()
|
defer accounting.Stats(ctx).ResetCounters()
|
||||||
|
|
||||||
const sizeCutoff = 2048
|
const sizeCutoff = 2048
|
||||||
|
@ -1817,7 +1788,6 @@ func TestCopyFileMaxTransfer(t *testing.T) {
|
||||||
func TestTouchDir(t *testing.T) {
|
func TestTouchDir(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if r.Fremote.Precision() == fs.ModTimeNotSupported {
|
if r.Fremote.Precision() == fs.ModTimeNotSupported {
|
||||||
t.Skip("Skipping test as remote does not support modtime")
|
t.Skip("Skipping test as remote does not support modtime")
|
||||||
|
|
|
@ -35,7 +35,6 @@ func rcNewRun(t *testing.T, method string) (*fstest.Run, *rc.Call) {
|
||||||
// operations/about: Return the space used on the remote
|
// operations/about: Return the space used on the remote
|
||||||
func TestRcAbout(t *testing.T) {
|
func TestRcAbout(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/about")
|
r, call := rcNewRun(t, "operations/about")
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
|
|
||||||
// Will get an error if remote doesn't support About
|
// Will get an error if remote doesn't support About
|
||||||
|
@ -58,7 +57,6 @@ func TestRcAbout(t *testing.T) {
|
||||||
// operations/cleanup: Remove trashed files in the remote or path
|
// operations/cleanup: Remove trashed files in the remote or path
|
||||||
func TestRcCleanup(t *testing.T) {
|
func TestRcCleanup(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/cleanup")
|
r, call := rcNewRun(t, "operations/cleanup")
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
in := rc.Params{
|
in := rc.Params{
|
||||||
"fs": r.LocalName,
|
"fs": r.LocalName,
|
||||||
|
@ -72,7 +70,6 @@ func TestRcCleanup(t *testing.T) {
|
||||||
// operations/copyfile: Copy a file from source remote to destination remote
|
// operations/copyfile: Copy a file from source remote to destination remote
|
||||||
func TestRcCopyfile(t *testing.T) {
|
func TestRcCopyfile(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/copyfile")
|
r, call := rcNewRun(t, "operations/copyfile")
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("file1", "file1 contents", t1)
|
file1 := r.WriteFile("file1", "file1 contents", t1)
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
r.CheckLocalItems(t, file1)
|
r.CheckLocalItems(t, file1)
|
||||||
|
@ -96,7 +93,6 @@ func TestRcCopyfile(t *testing.T) {
|
||||||
// operations/copyurl: Copy the URL to the object
|
// operations/copyurl: Copy the URL to the object
|
||||||
func TestRcCopyurl(t *testing.T) {
|
func TestRcCopyurl(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/copyurl")
|
r, call := rcNewRun(t, "operations/copyurl")
|
||||||
defer r.Finalise()
|
|
||||||
contents := "file1 contents\n"
|
contents := "file1 contents\n"
|
||||||
file1 := r.WriteFile("file1", contents, t1)
|
file1 := r.WriteFile("file1", contents, t1)
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
|
@ -159,7 +155,6 @@ func TestRcCopyurl(t *testing.T) {
|
||||||
// operations/delete: Remove files in the path
|
// operations/delete: Remove files in the path
|
||||||
func TestRcDelete(t *testing.T) {
|
func TestRcDelete(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/delete")
|
r, call := rcNewRun(t, "operations/delete")
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "small", "1234567890", t2) // 10 bytes
|
file1 := r.WriteObject(context.Background(), "small", "1234567890", t2) // 10 bytes
|
||||||
file2 := r.WriteObject(context.Background(), "medium", "------------------------------------------------------------", t1) // 60 bytes
|
file2 := r.WriteObject(context.Background(), "medium", "------------------------------------------------------------", t1) // 60 bytes
|
||||||
|
@ -179,7 +174,6 @@ func TestRcDelete(t *testing.T) {
|
||||||
// operations/deletefile: Remove the single file pointed to
|
// operations/deletefile: Remove the single file pointed to
|
||||||
func TestRcDeletefile(t *testing.T) {
|
func TestRcDeletefile(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/deletefile")
|
r, call := rcNewRun(t, "operations/deletefile")
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "small", "1234567890", t2) // 10 bytes
|
file1 := r.WriteObject(context.Background(), "small", "1234567890", t2) // 10 bytes
|
||||||
file2 := r.WriteObject(context.Background(), "medium", "------------------------------------------------------------", t1) // 60 bytes
|
file2 := r.WriteObject(context.Background(), "medium", "------------------------------------------------------------", t1) // 60 bytes
|
||||||
|
@ -199,7 +193,6 @@ func TestRcDeletefile(t *testing.T) {
|
||||||
// operations/list: List the given remote and path in JSON format.
|
// operations/list: List the given remote and path in JSON format.
|
||||||
func TestRcList(t *testing.T) {
|
func TestRcList(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/list")
|
r, call := rcNewRun(t, "operations/list")
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "a", "a", t1)
|
file1 := r.WriteObject(context.Background(), "a", "a", t1)
|
||||||
file2 := r.WriteObject(context.Background(), "subdir/b", "bb", t2)
|
file2 := r.WriteObject(context.Background(), "subdir/b", "bb", t2)
|
||||||
|
@ -264,7 +257,6 @@ func TestRcList(t *testing.T) {
|
||||||
// operations/stat: Stat the given remote and path in JSON format.
|
// operations/stat: Stat the given remote and path in JSON format.
|
||||||
func TestRcStat(t *testing.T) {
|
func TestRcStat(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/stat")
|
r, call := rcNewRun(t, "operations/stat")
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "subdir/a", "a", t1)
|
file1 := r.WriteObject(context.Background(), "subdir/a", "a", t1)
|
||||||
|
|
||||||
|
@ -318,7 +310,6 @@ func TestRcStat(t *testing.T) {
|
||||||
func TestRcMkdir(t *testing.T) {
|
func TestRcMkdir(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r, call := rcNewRun(t, "operations/mkdir")
|
r, call := rcNewRun(t, "operations/mkdir")
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
|
|
||||||
fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{}, []string{}, fs.GetModifyWindow(ctx, r.Fremote))
|
fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{}, []string{}, fs.GetModifyWindow(ctx, r.Fremote))
|
||||||
|
@ -337,7 +328,6 @@ func TestRcMkdir(t *testing.T) {
|
||||||
// operations/movefile: Move a file from source remote to destination remote
|
// operations/movefile: Move a file from source remote to destination remote
|
||||||
func TestRcMovefile(t *testing.T) {
|
func TestRcMovefile(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/movefile")
|
r, call := rcNewRun(t, "operations/movefile")
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("file1", "file1 contents", t1)
|
file1 := r.WriteFile("file1", "file1 contents", t1)
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
r.CheckLocalItems(t, file1)
|
r.CheckLocalItems(t, file1)
|
||||||
|
@ -362,7 +352,6 @@ func TestRcMovefile(t *testing.T) {
|
||||||
func TestRcPurge(t *testing.T) {
|
func TestRcPurge(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r, call := rcNewRun(t, "operations/purge")
|
r, call := rcNewRun(t, "operations/purge")
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(context.Background(), "subdir/file1", "subdir/file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "subdir/file1", "subdir/file1 contents", t1)
|
||||||
|
|
||||||
fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{file1}, []string{"subdir"}, fs.GetModifyWindow(ctx, r.Fremote))
|
fstest.CheckListingWithPrecision(t, r.Fremote, []fstest.Item{file1}, []string{"subdir"}, fs.GetModifyWindow(ctx, r.Fremote))
|
||||||
|
@ -382,7 +371,6 @@ func TestRcPurge(t *testing.T) {
|
||||||
func TestRcRmdir(t *testing.T) {
|
func TestRcRmdir(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r, call := rcNewRun(t, "operations/rmdir")
|
r, call := rcNewRun(t, "operations/rmdir")
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
assert.NoError(t, r.Fremote.Mkdir(context.Background(), "subdir"))
|
assert.NoError(t, r.Fremote.Mkdir(context.Background(), "subdir"))
|
||||||
|
|
||||||
|
@ -403,7 +391,6 @@ func TestRcRmdir(t *testing.T) {
|
||||||
func TestRcRmdirs(t *testing.T) {
|
func TestRcRmdirs(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r, call := rcNewRun(t, "operations/rmdirs")
|
r, call := rcNewRun(t, "operations/rmdirs")
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
assert.NoError(t, r.Fremote.Mkdir(context.Background(), "subdir"))
|
assert.NoError(t, r.Fremote.Mkdir(context.Background(), "subdir"))
|
||||||
assert.NoError(t, r.Fremote.Mkdir(context.Background(), "subdir/subsubdir"))
|
assert.NoError(t, r.Fremote.Mkdir(context.Background(), "subdir/subsubdir"))
|
||||||
|
@ -439,7 +426,6 @@ func TestRcRmdirs(t *testing.T) {
|
||||||
// operations/size: Count the number of bytes and files in remote
|
// operations/size: Count the number of bytes and files in remote
|
||||||
func TestRcSize(t *testing.T) {
|
func TestRcSize(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/size")
|
r, call := rcNewRun(t, "operations/size")
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(context.Background(), "small", "1234567890", t2) // 10 bytes
|
file1 := r.WriteObject(context.Background(), "small", "1234567890", t2) // 10 bytes
|
||||||
file2 := r.WriteObject(context.Background(), "subdir/medium", "------------------------------------------------------------", t1) // 60 bytes
|
file2 := r.WriteObject(context.Background(), "subdir/medium", "------------------------------------------------------------", t1) // 60 bytes
|
||||||
file3 := r.WriteObject(context.Background(), "subdir/subsubdir/large", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 50 bytes
|
file3 := r.WriteObject(context.Background(), "subdir/subsubdir/large", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 50 bytes
|
||||||
|
@ -460,7 +446,6 @@ func TestRcSize(t *testing.T) {
|
||||||
// operations/publiclink: Create or retrieve a public link to the given file or folder.
|
// operations/publiclink: Create or retrieve a public link to the given file or folder.
|
||||||
func TestRcPublicLink(t *testing.T) {
|
func TestRcPublicLink(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/publiclink")
|
r, call := rcNewRun(t, "operations/publiclink")
|
||||||
defer r.Finalise()
|
|
||||||
in := rc.Params{
|
in := rc.Params{
|
||||||
"fs": r.FremoteName,
|
"fs": r.FremoteName,
|
||||||
"remote": "",
|
"remote": "",
|
||||||
|
@ -475,7 +460,6 @@ func TestRcPublicLink(t *testing.T) {
|
||||||
// operations/fsinfo: Return information about the remote
|
// operations/fsinfo: Return information about the remote
|
||||||
func TestRcFsInfo(t *testing.T) {
|
func TestRcFsInfo(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/fsinfo")
|
r, call := rcNewRun(t, "operations/fsinfo")
|
||||||
defer r.Finalise()
|
|
||||||
in := rc.Params{
|
in := rc.Params{
|
||||||
"fs": r.FremoteName,
|
"fs": r.FremoteName,
|
||||||
}
|
}
|
||||||
|
@ -502,7 +486,6 @@ func TestRcFsInfo(t *testing.T) {
|
||||||
// operations/uploadfile : Tests if upload file succeeds
|
// operations/uploadfile : Tests if upload file succeeds
|
||||||
func TestUploadFile(t *testing.T) {
|
func TestUploadFile(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "operations/uploadfile")
|
r, call := rcNewRun(t, "operations/uploadfile")
|
||||||
defer r.Finalise()
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
testFileName := "test.txt"
|
testFileName := "test.txt"
|
||||||
|
@ -558,7 +541,6 @@ func TestUploadFile(t *testing.T) {
|
||||||
// operations/command: Runs a backend command
|
// operations/command: Runs a backend command
|
||||||
func TestRcCommand(t *testing.T) {
|
func TestRcCommand(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "backend/command")
|
r, call := rcNewRun(t, "backend/command")
|
||||||
defer r.Finalise()
|
|
||||||
in := rc.Params{
|
in := rc.Params{
|
||||||
"fs": r.FremoteName,
|
"fs": r.FremoteName,
|
||||||
"command": "noop",
|
"command": "noop",
|
||||||
|
|
|
@ -2,7 +2,6 @@ package webgui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -22,7 +21,7 @@ func init() {
|
||||||
rcflags.Opt.WebUI = true
|
rcflags.Opt.WebUI = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func setCacheDir(t *testing.T) string {
|
func setCacheDir(t *testing.T) {
|
||||||
cacheDir := t.TempDir()
|
cacheDir := t.TempDir()
|
||||||
PluginsPath = filepath.Join(cacheDir, "plugins")
|
PluginsPath = filepath.Join(cacheDir, "plugins")
|
||||||
pluginsConfigPath = filepath.Join(cacheDir, "config")
|
pluginsConfigPath = filepath.Join(cacheDir, "config")
|
||||||
|
@ -30,11 +29,6 @@ func setCacheDir(t *testing.T) string {
|
||||||
loadedPlugins = newPlugins(availablePluginsJSONPath)
|
loadedPlugins = newPlugins(availablePluginsJSONPath)
|
||||||
err := loadedPlugins.readFromFile()
|
err := loadedPlugins.readFromFile()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
return cacheDir
|
|
||||||
}
|
|
||||||
|
|
||||||
func cleanCacheDir(t *testing.T, cacheDir string) {
|
|
||||||
_ = os.RemoveAll(cacheDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addPlugin(t *testing.T) {
|
func addPlugin(t *testing.T) {
|
||||||
|
@ -88,8 +82,7 @@ func removePlugin(t *testing.T) {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func TestAddPlugin(t *testing.T) {
|
func TestAddPlugin(t *testing.T) {
|
||||||
cacheDir := setCacheDir(t)
|
setCacheDir(t)
|
||||||
defer cleanCacheDir(t, cacheDir)
|
|
||||||
|
|
||||||
addPlugin(t)
|
addPlugin(t)
|
||||||
_, ok := loadedPlugins.LoadedPlugins[testPluginKey]
|
_, ok := loadedPlugins.LoadedPlugins[testPluginKey]
|
||||||
|
@ -101,8 +94,7 @@ func TestAddPlugin(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListPlugins(t *testing.T) {
|
func TestListPlugins(t *testing.T) {
|
||||||
cacheDir := setCacheDir(t)
|
setCacheDir(t)
|
||||||
defer cleanCacheDir(t, cacheDir)
|
|
||||||
|
|
||||||
addPlugin := rc.Calls.Get("pluginsctl/listPlugins")
|
addPlugin := rc.Calls.Get("pluginsctl/listPlugins")
|
||||||
assert.NotNil(t, addPlugin)
|
assert.NotNil(t, addPlugin)
|
||||||
|
@ -117,8 +109,7 @@ func TestListPlugins(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemovePlugin(t *testing.T) {
|
func TestRemovePlugin(t *testing.T) {
|
||||||
cacheDir := setCacheDir(t)
|
setCacheDir(t)
|
||||||
defer cleanCacheDir(t, cacheDir)
|
|
||||||
|
|
||||||
addPlugin(t)
|
addPlugin(t)
|
||||||
removePluginCall := rc.Calls.Get("pluginsctl/removePlugin")
|
removePluginCall := rc.Calls.Get("pluginsctl/removePlugin")
|
||||||
|
|
|
@ -26,7 +26,6 @@ func rcNewRun(t *testing.T, method string) (*fstest.Run, *rc.Call) {
|
||||||
// sync/copy: copy a directory from source remote to destination remote
|
// sync/copy: copy a directory from source remote to destination remote
|
||||||
func TestRcCopy(t *testing.T) {
|
func TestRcCopy(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "sync/copy")
|
r, call := rcNewRun(t, "sync/copy")
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteBoth(context.Background(), "file1", "file1 contents", t1)
|
file1 := r.WriteBoth(context.Background(), "file1", "file1 contents", t1)
|
||||||
|
@ -51,7 +50,6 @@ func TestRcCopy(t *testing.T) {
|
||||||
// sync/move: move a directory from source remote to destination remote
|
// sync/move: move a directory from source remote to destination remote
|
||||||
func TestRcMove(t *testing.T) {
|
func TestRcMove(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "sync/move")
|
r, call := rcNewRun(t, "sync/move")
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteBoth(context.Background(), "file1", "file1 contents", t1)
|
file1 := r.WriteBoth(context.Background(), "file1", "file1 contents", t1)
|
||||||
|
@ -76,7 +74,6 @@ func TestRcMove(t *testing.T) {
|
||||||
// sync/sync: sync a directory from source remote to destination remote
|
// sync/sync: sync a directory from source remote to destination remote
|
||||||
func TestRcSync(t *testing.T) {
|
func TestRcSync(t *testing.T) {
|
||||||
r, call := rcNewRun(t, "sync/sync")
|
r, call := rcNewRun(t, "sync/sync")
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(context.Background(), r.Fremote)
|
r.Mkdir(context.Background(), r.Fremote)
|
||||||
|
|
||||||
file1 := r.WriteBoth(context.Background(), "file1", "file1 contents", t1)
|
file1 := r.WriteBoth(context.Background(), "file1", "file1 contents", t1)
|
||||||
|
|
|
@ -41,7 +41,6 @@ func TestCopyWithDryRun(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
|
@ -57,7 +56,6 @@ func TestCopyWithDryRun(t *testing.T) {
|
||||||
func TestCopy(t *testing.T) {
|
func TestCopy(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
|
@ -71,7 +69,6 @@ func TestCopy(t *testing.T) {
|
||||||
func TestCopyMissingDirectory(t *testing.T) {
|
func TestCopyMissingDirectory(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
|
||||||
nonExistingFs, err := fs.NewFs(ctx, "/non-existing")
|
nonExistingFs, err := fs.NewFs(ctx, "/non-existing")
|
||||||
|
@ -88,7 +85,6 @@ func TestCopyNoTraverse(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.NoTraverse = true
|
ci.NoTraverse = true
|
||||||
|
|
||||||
|
@ -106,7 +102,6 @@ func TestCopyCheckFirst(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.CheckFirst = true
|
ci.CheckFirst = true
|
||||||
|
|
||||||
|
@ -124,7 +119,6 @@ func TestSyncNoTraverse(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.NoTraverse = true
|
ci.NoTraverse = true
|
||||||
|
|
||||||
|
@ -143,7 +137,6 @@ func TestCopyWithDepth(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
file2 := r.WriteFile("hello world2", "hello world2", t2)
|
file2 := r.WriteFile("hello world2", "hello world2", t2)
|
||||||
|
|
||||||
|
@ -162,7 +155,6 @@ func testCopyWithFilesFrom(t *testing.T, noTraverse bool) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("potato2", "hello world", t1)
|
file1 := r.WriteFile("potato2", "hello world", t1)
|
||||||
file2 := r.WriteFile("hello world2", "hello world2", t2)
|
file2 := r.WriteFile("hello world2", "hello world2", t2)
|
||||||
|
|
||||||
|
@ -190,7 +182,6 @@ func TestCopyWithFilesFromAndNoTraverse(t *testing.T) { testCopyWithFilesFrom(t,
|
||||||
func TestCopyEmptyDirectories(t *testing.T) {
|
func TestCopyEmptyDirectories(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
err := operations.Mkdir(ctx, r.Flocal, "sub dir2")
|
err := operations.Mkdir(ctx, r.Flocal, "sub dir2")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -215,7 +206,6 @@ func TestCopyEmptyDirectories(t *testing.T) {
|
||||||
func TestMoveEmptyDirectories(t *testing.T) {
|
func TestMoveEmptyDirectories(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
err := operations.Mkdir(ctx, r.Flocal, "sub dir2")
|
err := operations.Mkdir(ctx, r.Flocal, "sub dir2")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -240,7 +230,6 @@ func TestMoveEmptyDirectories(t *testing.T) {
|
||||||
func TestSyncEmptyDirectories(t *testing.T) {
|
func TestSyncEmptyDirectories(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
err := operations.Mkdir(ctx, r.Flocal, "sub dir2")
|
err := operations.Mkdir(ctx, r.Flocal, "sub dir2")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -265,7 +254,6 @@ func TestSyncEmptyDirectories(t *testing.T) {
|
||||||
func TestServerSideCopy(t *testing.T) {
|
func TestServerSideCopy(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
|
||||||
|
@ -285,7 +273,6 @@ func TestServerSideCopy(t *testing.T) {
|
||||||
func TestCopyAfterDelete(t *testing.T) {
|
func TestCopyAfterDelete(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
||||||
r.CheckLocalItems(t)
|
r.CheckLocalItems(t)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
@ -304,7 +291,6 @@ func TestCopyAfterDelete(t *testing.T) {
|
||||||
func TestCopyRedownload(t *testing.T) {
|
func TestCopyRedownload(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
file1 := r.WriteObject(ctx, "sub dir/hello world", "hello world", t1)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
|
||||||
|
@ -322,7 +308,6 @@ func TestSyncBasedOnCheckSum(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
ci.CheckSum = true
|
ci.CheckSum = true
|
||||||
|
|
||||||
file1 := r.WriteFile("check sum", "-", t1)
|
file1 := r.WriteFile("check sum", "-", t1)
|
||||||
|
@ -357,7 +342,6 @@ func TestSyncSizeOnly(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
ci.SizeOnly = true
|
ci.SizeOnly = true
|
||||||
|
|
||||||
file1 := r.WriteFile("sizeonly", "potato", t1)
|
file1 := r.WriteFile("sizeonly", "potato", t1)
|
||||||
|
@ -392,7 +376,6 @@ func TestSyncIgnoreSize(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
ci.IgnoreSize = true
|
ci.IgnoreSize = true
|
||||||
|
|
||||||
file1 := r.WriteFile("ignore-size", "contents", t1)
|
file1 := r.WriteFile("ignore-size", "contents", t1)
|
||||||
|
@ -424,7 +407,6 @@ func TestSyncIgnoreTimes(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "existing", "potato", t1)
|
file1 := r.WriteBoth(ctx, "existing", "potato", t1)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
|
||||||
|
@ -454,7 +436,6 @@ func TestSyncIgnoreExisting(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("existing", "potato", t1)
|
file1 := r.WriteFile("existing", "potato", t1)
|
||||||
|
|
||||||
ci.IgnoreExisting = true
|
ci.IgnoreExisting = true
|
||||||
|
@ -479,7 +460,6 @@ func TestSyncIgnoreErrors(t *testing.T) {
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
ci.IgnoreErrors = true
|
ci.IgnoreErrors = true
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("a/potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteFile("a/potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteObject(ctx, "b/potato", "SMALLER BUT SAME DATE", t2)
|
file2 := r.WriteObject(ctx, "b/potato", "SMALLER BUT SAME DATE", t2)
|
||||||
file3 := r.WriteBoth(ctx, "c/non empty space", "AhHa!", t2)
|
file3 := r.WriteBoth(ctx, "c/non empty space", "AhHa!", t2)
|
||||||
|
@ -541,7 +521,6 @@ func TestSyncAfterChangingModtimeOnly(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("empty space", "-", t2)
|
file1 := r.WriteFile("empty space", "-", t2)
|
||||||
file2 := r.WriteObject(ctx, "empty space", "-", t1)
|
file2 := r.WriteObject(ctx, "empty space", "-", t1)
|
||||||
|
|
||||||
|
@ -571,7 +550,6 @@ func TestSyncAfterChangingModtimeOnlyWithNoUpdateModTime(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if r.Fremote.Hashes().Count() == 0 {
|
if r.Fremote.Hashes().Count() == 0 {
|
||||||
t.Logf("Can't check this if no hashes supported")
|
t.Logf("Can't check this if no hashes supported")
|
||||||
|
@ -597,7 +575,6 @@ func TestSyncAfterChangingModtimeOnlyWithNoUpdateModTime(t *testing.T) {
|
||||||
func TestSyncDoesntUpdateModtime(t *testing.T) {
|
func TestSyncDoesntUpdateModtime(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
if fs.GetModifyWindow(ctx, r.Fremote) == fs.ModTimeNotSupported {
|
if fs.GetModifyWindow(ctx, r.Fremote) == fs.ModTimeNotSupported {
|
||||||
t.Skip("Can't run this test on fs which doesn't support mod time")
|
t.Skip("Can't run this test on fs which doesn't support mod time")
|
||||||
}
|
}
|
||||||
|
@ -622,7 +599,6 @@ func TestSyncDoesntUpdateModtime(t *testing.T) {
|
||||||
func TestSyncAfterAddingAFile(t *testing.T) {
|
func TestSyncAfterAddingAFile(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file1 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
file2 := r.WriteFile("potato", "------------------------------------------------------------", t3)
|
file2 := r.WriteFile("potato", "------------------------------------------------------------", t3)
|
||||||
|
|
||||||
|
@ -639,7 +615,6 @@ func TestSyncAfterAddingAFile(t *testing.T) {
|
||||||
func TestSyncAfterChangingFilesSizeOnly(t *testing.T) {
|
func TestSyncAfterChangingFilesSizeOnly(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteObject(ctx, "potato", "------------------------------------------------------------", t3)
|
file1 := r.WriteObject(ctx, "potato", "------------------------------------------------------------", t3)
|
||||||
file2 := r.WriteFile("potato", "smaller but same date", t3)
|
file2 := r.WriteFile("potato", "smaller but same date", t3)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
@ -657,7 +632,6 @@ func TestSyncAfterChangingFilesSizeOnly(t *testing.T) {
|
||||||
func TestSyncAfterChangingContentsOnly(t *testing.T) {
|
func TestSyncAfterChangingContentsOnly(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
var file1 fstest.Item
|
var file1 fstest.Item
|
||||||
if r.Fremote.Precision() == fs.ModTimeNotSupported {
|
if r.Fremote.Precision() == fs.ModTimeNotSupported {
|
||||||
t.Logf("ModTimeNotSupported so forcing file to be a different size")
|
t.Logf("ModTimeNotSupported so forcing file to be a different size")
|
||||||
|
@ -681,7 +655,6 @@ func TestSyncAfterRemovingAFileAndAddingAFileDryRun(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteFile("potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteObject(ctx, "potato", "SMALLER BUT SAME DATE", t2)
|
file2 := r.WriteObject(ctx, "potato", "SMALLER BUT SAME DATE", t2)
|
||||||
file3 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file3 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
|
@ -699,7 +672,6 @@ func TestSyncAfterRemovingAFileAndAddingAFileDryRun(t *testing.T) {
|
||||||
// Sync after removing a file and adding a file
|
// Sync after removing a file and adding a file
|
||||||
func testSyncAfterRemovingAFileAndAddingAFile(ctx context.Context, t *testing.T) {
|
func testSyncAfterRemovingAFileAndAddingAFile(ctx context.Context, t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteFile("potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteObject(ctx, "potato", "SMALLER BUT SAME DATE", t2)
|
file2 := r.WriteObject(ctx, "potato", "SMALLER BUT SAME DATE", t2)
|
||||||
file3 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file3 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
|
@ -720,7 +692,6 @@ func TestSyncAfterRemovingAFileAndAddingAFile(t *testing.T) {
|
||||||
// Sync after removing a file and adding a file
|
// Sync after removing a file and adding a file
|
||||||
func testSyncAfterRemovingAFileAndAddingAFileSubDir(ctx context.Context, t *testing.T) {
|
func testSyncAfterRemovingAFileAndAddingAFileSubDir(ctx context.Context, t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("a/potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteFile("a/potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteObject(ctx, "b/potato", "SMALLER BUT SAME DATE", t2)
|
file2 := r.WriteObject(ctx, "b/potato", "SMALLER BUT SAME DATE", t2)
|
||||||
file3 := r.WriteBoth(ctx, "c/non empty space", "AhHa!", t2)
|
file3 := r.WriteBoth(ctx, "c/non empty space", "AhHa!", t2)
|
||||||
|
@ -788,7 +759,6 @@ func TestSyncAfterRemovingAFileAndAddingAFileSubDir(t *testing.T) {
|
||||||
func TestSyncAfterRemovingAFileAndAddingAFileSubDirWithErrors(t *testing.T) {
|
func TestSyncAfterRemovingAFileAndAddingAFileSubDirWithErrors(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("a/potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteFile("a/potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteObject(ctx, "b/potato", "SMALLER BUT SAME DATE", t2)
|
file2 := r.WriteObject(ctx, "b/potato", "SMALLER BUT SAME DATE", t2)
|
||||||
file3 := r.WriteBoth(ctx, "c/non empty space", "AhHa!", t2)
|
file3 := r.WriteBoth(ctx, "c/non empty space", "AhHa!", t2)
|
||||||
|
@ -882,7 +852,6 @@ func TestCopyDeleteBefore(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.DeleteMode = fs.DeleteModeBefore
|
ci.DeleteMode = fs.DeleteModeBefore
|
||||||
|
|
||||||
|
@ -903,7 +872,6 @@ func TestCopyDeleteBefore(t *testing.T) {
|
||||||
func TestSyncWithExclude(t *testing.T) {
|
func TestSyncWithExclude(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1)
|
||||||
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
file3 := r.WriteFile("enormous", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytes
|
file3 := r.WriteFile("enormous", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytes
|
||||||
|
@ -932,7 +900,6 @@ func TestSyncWithExclude(t *testing.T) {
|
||||||
func TestSyncWithExcludeAndDeleteExcluded(t *testing.T) {
|
func TestSyncWithExcludeAndDeleteExcluded(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1) // 60 bytes
|
file1 := r.WriteBoth(ctx, "potato2", "------------------------------------------------------------", t1) // 60 bytes
|
||||||
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
file2 := r.WriteBoth(ctx, "empty space", "-", t2)
|
||||||
file3 := r.WriteBoth(ctx, "enormous", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytes
|
file3 := r.WriteBoth(ctx, "enormous", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", t1) // 100 bytes
|
||||||
|
@ -963,7 +930,6 @@ func TestSyncWithUpdateOlder(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
if fs.GetModifyWindow(ctx, r.Fremote) == fs.ModTimeNotSupported {
|
if fs.GetModifyWindow(ctx, r.Fremote) == fs.ModTimeNotSupported {
|
||||||
t.Skip("Can't run this test on fs which doesn't support mod time")
|
t.Skip("Can't run this test on fs which doesn't support mod time")
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +975,6 @@ func testSyncWithMaxDuration(t *testing.T, cutoffMode fs.CutoffMode) {
|
||||||
t.Skip("Skipping test on non local remote")
|
t.Skip("Skipping test on non local remote")
|
||||||
}
|
}
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
maxDuration := 250 * time.Millisecond
|
maxDuration := 250 * time.Millisecond
|
||||||
ci.MaxDuration = maxDuration
|
ci.MaxDuration = maxDuration
|
||||||
|
@ -1063,7 +1028,6 @@ func TestSyncWithTrackRenames(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.TrackRenames = true
|
ci.TrackRenames = true
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -1135,7 +1099,6 @@ func TestSyncWithTrackRenamesStrategyModtime(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.TrackRenames = true
|
ci.TrackRenames = true
|
||||||
ci.TrackRenamesStrategy = "modtime"
|
ci.TrackRenamesStrategy = "modtime"
|
||||||
|
@ -1171,7 +1134,6 @@ func TestSyncWithTrackRenamesStrategyLeaf(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.TrackRenames = true
|
ci.TrackRenames = true
|
||||||
ci.TrackRenamesStrategy = "leaf"
|
ci.TrackRenamesStrategy = "leaf"
|
||||||
|
@ -1285,7 +1247,6 @@ func testServerSideMove(ctx context.Context, t *testing.T, r *fstest.Run, withFi
|
||||||
func TestMoveWithDeleteEmptySrcDirs(t *testing.T) {
|
func TestMoveWithDeleteEmptySrcDirs(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
file2 := r.WriteFile("nested/sub dir/file", "nested", t1)
|
file2 := r.WriteFile("nested/sub dir/file", "nested", t1)
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
@ -1305,7 +1266,6 @@ func TestMoveWithDeleteEmptySrcDirs(t *testing.T) {
|
||||||
func TestMoveWithoutDeleteEmptySrcDirs(t *testing.T) {
|
func TestMoveWithoutDeleteEmptySrcDirs(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
file1 := r.WriteFile("sub dir/hello world", "hello world", t1)
|
||||||
file2 := r.WriteFile("nested/sub dir/file", "nested", t1)
|
file2 := r.WriteFile("nested/sub dir/file", "nested", t1)
|
||||||
r.Mkdir(ctx, r.Fremote)
|
r.Mkdir(ctx, r.Fremote)
|
||||||
|
@ -1329,7 +1289,6 @@ func TestMoveWithIgnoreExisting(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
file1 := r.WriteFile("existing", "potato", t1)
|
file1 := r.WriteFile("existing", "potato", t1)
|
||||||
file2 := r.WriteFile("existing-b", "tomato", t1)
|
file2 := r.WriteFile("existing-b", "tomato", t1)
|
||||||
|
|
||||||
|
@ -1380,7 +1339,6 @@ func TestMoveWithIgnoreExisting(t *testing.T) {
|
||||||
func TestServerSideMove(t *testing.T) {
|
func TestServerSideMove(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
testServerSideMove(ctx, t, r, false, false)
|
testServerSideMove(ctx, t, r, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,7 +1346,6 @@ func TestServerSideMove(t *testing.T) {
|
||||||
func TestServerSideMoveWithFilter(t *testing.T) {
|
func TestServerSideMoveWithFilter(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
fi, err := filter.NewFilter(nil)
|
fi, err := filter.NewFilter(nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -1402,7 +1359,6 @@ func TestServerSideMoveWithFilter(t *testing.T) {
|
||||||
func TestServerSideMoveDeleteEmptySourceDirs(t *testing.T) {
|
func TestServerSideMoveDeleteEmptySourceDirs(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
testServerSideMove(ctx, t, r, false, true)
|
testServerSideMove(ctx, t, r, false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1410,7 +1366,6 @@ func TestServerSideMoveDeleteEmptySourceDirs(t *testing.T) {
|
||||||
func TestServerSideMoveOverlap(t *testing.T) {
|
func TestServerSideMoveOverlap(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if r.Fremote.Features().DirMove != nil {
|
if r.Fremote.Features().DirMove != nil {
|
||||||
t.Skip("Skipping test as remote supports DirMove")
|
t.Skip("Skipping test as remote supports DirMove")
|
||||||
|
@ -1441,7 +1396,6 @@ func TestServerSideMoveOverlap(t *testing.T) {
|
||||||
func TestSyncOverlap(t *testing.T) {
|
func TestSyncOverlap(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
subRemoteName := r.FremoteName + "/rclone-sync-test"
|
subRemoteName := r.FremoteName + "/rclone-sync-test"
|
||||||
FremoteSync, err := fs.NewFs(ctx, subRemoteName)
|
FremoteSync, err := fs.NewFs(ctx, subRemoteName)
|
||||||
|
@ -1463,7 +1417,6 @@ func TestSyncOverlap(t *testing.T) {
|
||||||
func TestSyncOverlapWithFilter(t *testing.T) {
|
func TestSyncOverlapWithFilter(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
fi, err := filter.NewFilter(nil)
|
fi, err := filter.NewFilter(nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -1521,7 +1474,6 @@ func TestSyncCompareDest(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.CompareDest = []string{r.FremoteName + "/CompareDest"}
|
ci.CompareDest = []string{r.FremoteName + "/CompareDest"}
|
||||||
|
|
||||||
|
@ -1637,7 +1589,6 @@ func TestSyncMultipleCompareDest(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
precision := fs.GetModifyWindow(ctx, r.Fremote, r.Flocal)
|
precision := fs.GetModifyWindow(ctx, r.Fremote, r.Flocal)
|
||||||
|
|
||||||
ci.CompareDest = []string{r.FremoteName + "/pre-dest1", r.FremoteName + "/pre-dest2"}
|
ci.CompareDest = []string{r.FremoteName + "/pre-dest1", r.FremoteName + "/pre-dest2"}
|
||||||
|
@ -1669,7 +1620,6 @@ func TestSyncCopyDest(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if r.Fremote.Features().Copy == nil {
|
if r.Fremote.Features().Copy == nil {
|
||||||
t.Skip("Skipping test as remote does not support server-side copy")
|
t.Skip("Skipping test as remote does not support server-side copy")
|
||||||
|
@ -1771,7 +1721,6 @@ func testSyncBackupDir(t *testing.T, backupDir string, suffix string, suffixKeep
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if !operations.CanServerSideMove(r.Fremote) {
|
if !operations.CanServerSideMove(r.Fremote) {
|
||||||
t.Skip("Skipping test as remote does not support server-side move")
|
t.Skip("Skipping test as remote does not support server-side move")
|
||||||
|
@ -1869,7 +1818,6 @@ func testSyncSuffix(t *testing.T, suffix string, suffixKeepExtension bool) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if !operations.CanServerSideMove(r.Fremote) {
|
if !operations.CanServerSideMove(r.Fremote) {
|
||||||
t.Skip("Skipping test as remote does not support server-side move")
|
t.Skip("Skipping test as remote does not support server-side move")
|
||||||
|
@ -1957,7 +1905,6 @@ func TestSyncUTFNorm(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
// Two strings with different unicode normalization (from OS X)
|
// Two strings with different unicode normalization (from OS X)
|
||||||
Encoding1 := "Testêé"
|
Encoding1 := "Testêé"
|
||||||
|
@ -1988,7 +1935,6 @@ func TestSyncImmutable(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
ci.Immutable = true
|
ci.Immutable = true
|
||||||
|
|
||||||
|
@ -2022,7 +1968,6 @@ func TestSyncIgnoreCase(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, ci := fs.AddConfig(ctx)
|
ctx, ci := fs.AddConfig(ctx)
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
// Only test if filesystems are case sensitive
|
// Only test if filesystems are case sensitive
|
||||||
if r.Fremote.Features().CaseInsensitive || r.Flocal.Features().CaseInsensitive {
|
if r.Fremote.Features().CaseInsensitive || r.Flocal.Features().CaseInsensitive {
|
||||||
|
@ -2056,7 +2001,6 @@ func TestMaxTransfer(t *testing.T) {
|
||||||
|
|
||||||
test := func(t *testing.T, cutoff fs.CutoffMode) {
|
test := func(t *testing.T, cutoff fs.CutoffMode) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
ci.CutoffMode = cutoff
|
ci.CutoffMode = cutoff
|
||||||
|
|
||||||
if r.Fremote.Name() != "local" {
|
if r.Fremote.Name() != "local" {
|
||||||
|
@ -2098,7 +2042,6 @@ func testSyncConcurrent(t *testing.T, subtest string) {
|
||||||
ci.Transfers = NTRANSFERS
|
ci.Transfers = NTRANSFERS
|
||||||
|
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
stats := accounting.GlobalStats()
|
stats := accounting.GlobalStats()
|
||||||
|
|
||||||
itemsBefore := []fstest.Item{}
|
itemsBefore := []fstest.Item{}
|
||||||
|
|
|
@ -178,6 +178,7 @@ func newRunIndividual(t *testing.T, individual bool) *Run {
|
||||||
r.Logf = t.Logf
|
r.Logf = t.Logf
|
||||||
r.Fatalf = t.Fatalf
|
r.Fatalf = t.Fatalf
|
||||||
r.Logf("Remote %q, Local %q, Modify Window %q", r.Fremote, r.Flocal, fs.GetModifyWindow(ctx, r.Fremote))
|
r.Logf("Remote %q, Local %q, Modify Window %q", r.Fremote, r.Flocal, fs.GetModifyWindow(ctx, r.Fremote))
|
||||||
|
t.Cleanup(r.Finalise)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,8 +187,6 @@ func newRunIndividual(t *testing.T, individual bool) *Run {
|
||||||
//
|
//
|
||||||
// r.Flocal is an empty local Fs
|
// r.Flocal is an empty local Fs
|
||||||
// r.Fremote is an empty remote Fs
|
// r.Fremote is an empty remote Fs
|
||||||
//
|
|
||||||
// Finalise() will tidy them away when done.
|
|
||||||
func NewRun(t *testing.T) *Run {
|
func NewRun(t *testing.T) *Run {
|
||||||
return newRunIndividual(t, *Individual)
|
return newRunIndividual(t, *Individual)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDirHandleMethods(t *testing.T) {
|
func TestDirHandleMethods(t *testing.T) {
|
||||||
_, _, dir, _, cleanup := dirCreate(t)
|
_, _, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
h, err := dir.Open(os.O_RDONLY)
|
h, err := dir.Open(os.O_RDONLY)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -38,8 +37,7 @@ func TestDirHandleMethods(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirHandleReaddir(t *testing.T) {
|
func TestDirHandleReaddir(t *testing.T) {
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
||||||
file2 := r.WriteObject(context.Background(), "dir/file2", "file2- contents", t2)
|
file2 := r.WriteObject(context.Background(), "dir/file2", "file2- contents", t2)
|
||||||
|
@ -93,8 +91,7 @@ func TestDirHandleReaddir(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirHandleReaddirnames(t *testing.T) {
|
func TestDirHandleReaddirnames(t *testing.T) {
|
||||||
_, _, dir, _, cleanup := dirCreate(t)
|
_, _, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
fh, err := dir.Open(os.O_RDONLY)
|
fh, err := dir.Open(os.O_RDONLY)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -15,8 +15,8 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dirCreate(t *testing.T) (r *fstest.Run, vfs *VFS, dir *Dir, item fstest.Item, cleanup func()) {
|
func dirCreate(t *testing.T) (r *fstest.Run, vfs *VFS, dir *Dir, item fstest.Item) {
|
||||||
r, vfs, cleanup = newTestVFS(t)
|
r, vfs = newTestVFS(t)
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
@ -25,12 +25,11 @@ func dirCreate(t *testing.T) (r *fstest.Run, vfs *VFS, dir *Dir, item fstest.Ite
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, node.IsDir())
|
require.True(t, node.IsDir())
|
||||||
|
|
||||||
return r, vfs, node.(*Dir), file1, cleanup
|
return r, vfs, node.(*Dir), file1
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirMethods(t *testing.T) {
|
func TestDirMethods(t *testing.T) {
|
||||||
_, vfs, dir, _, cleanup := dirCreate(t)
|
_, vfs, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// String
|
// String
|
||||||
assert.Equal(t, "dir/", dir.String())
|
assert.Equal(t, "dir/", dir.String())
|
||||||
|
@ -81,8 +80,7 @@ func TestDirMethods(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirForgetAll(t *testing.T) {
|
func TestDirForgetAll(t *testing.T) {
|
||||||
_, vfs, dir, file1, cleanup := dirCreate(t)
|
_, vfs, dir, file1 := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Make sure / and dir are in cache
|
// Make sure / and dir are in cache
|
||||||
_, err := vfs.Stat(file1.Path)
|
_, err := vfs.Stat(file1.Path)
|
||||||
|
@ -109,8 +107,7 @@ func TestDirForgetAll(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirForgetPath(t *testing.T) {
|
func TestDirForgetPath(t *testing.T) {
|
||||||
_, vfs, dir, file1, cleanup := dirCreate(t)
|
_, vfs, dir, file1 := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Make sure / and dir are in cache
|
// Make sure / and dir are in cache
|
||||||
_, err := vfs.Stat(file1.Path)
|
_, err := vfs.Stat(file1.Path)
|
||||||
|
@ -141,8 +138,7 @@ func TestDirForgetPath(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirWalk(t *testing.T) {
|
func TestDirWalk(t *testing.T) {
|
||||||
r, vfs, _, file1, cleanup := dirCreate(t)
|
r, vfs, _, file1 := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
file2 := r.WriteObject(context.Background(), "fil/a/b/c", "super long file", t1)
|
file2 := r.WriteObject(context.Background(), "fil/a/b/c", "super long file", t1)
|
||||||
r.CheckRemoteItems(t, file1, file2)
|
r.CheckRemoteItems(t, file1, file2)
|
||||||
|
@ -210,8 +206,7 @@ func TestDirWalk(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirSetModTime(t *testing.T) {
|
func TestDirSetModTime(t *testing.T) {
|
||||||
_, vfs, dir, _, cleanup := dirCreate(t)
|
_, vfs, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
err := dir.SetModTime(t1)
|
err := dir.SetModTime(t1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -227,8 +222,7 @@ func TestDirSetModTime(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirStat(t *testing.T) {
|
func TestDirStat(t *testing.T) {
|
||||||
_, _, dir, _, cleanup := dirCreate(t)
|
_, _, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
node, err := dir.Stat("file1")
|
node, err := dir.Stat("file1")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -253,8 +247,7 @@ func checkListing(t *testing.T, dir *Dir, want []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirReadDirAll(t *testing.T) {
|
func TestDirReadDirAll(t *testing.T) {
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
||||||
file2 := r.WriteObject(context.Background(), "dir/file2", "file2- contents", t2)
|
file2 := r.WriteObject(context.Background(), "dir/file2", "file2- contents", t2)
|
||||||
|
@ -334,8 +327,7 @@ func TestDirReadDirAll(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirOpen(t *testing.T) {
|
func TestDirOpen(t *testing.T) {
|
||||||
_, _, dir, _, cleanup := dirCreate(t)
|
_, _, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
fd, err := dir.Open(os.O_RDONLY)
|
fd, err := dir.Open(os.O_RDONLY)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -348,8 +340,7 @@ func TestDirOpen(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirCreate(t *testing.T) {
|
func TestDirCreate(t *testing.T) {
|
||||||
_, vfs, dir, _, cleanup := dirCreate(t)
|
_, vfs, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
file, err := dir.Create("potato", os.O_WRONLY|os.O_CREATE)
|
file, err := dir.Create("potato", os.O_WRONLY|os.O_CREATE)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -388,8 +379,7 @@ func TestDirCreate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirMkdir(t *testing.T) {
|
func TestDirMkdir(t *testing.T) {
|
||||||
r, vfs, dir, file1, cleanup := dirCreate(t)
|
r, vfs, dir, file1 := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
_, err := dir.Mkdir("file1")
|
_, err := dir.Mkdir("file1")
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
@ -410,8 +400,7 @@ func TestDirMkdir(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirMkdirSub(t *testing.T) {
|
func TestDirMkdirSub(t *testing.T) {
|
||||||
r, vfs, dir, file1, cleanup := dirCreate(t)
|
r, vfs, dir, file1 := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
_, err := dir.Mkdir("file1")
|
_, err := dir.Mkdir("file1")
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
|
@ -436,8 +425,7 @@ func TestDirMkdirSub(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirRemove(t *testing.T) {
|
func TestDirRemove(t *testing.T) {
|
||||||
r, vfs, dir, _, cleanup := dirCreate(t)
|
r, vfs, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// check directory is there
|
// check directory is there
|
||||||
node, err := vfs.Stat("dir")
|
node, err := vfs.Stat("dir")
|
||||||
|
@ -476,8 +464,7 @@ func TestDirRemove(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirRemoveAll(t *testing.T) {
|
func TestDirRemoveAll(t *testing.T) {
|
||||||
r, vfs, dir, _, cleanup := dirCreate(t)
|
r, vfs, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Remove the directory and contents
|
// Remove the directory and contents
|
||||||
err := dir.RemoveAll()
|
err := dir.RemoveAll()
|
||||||
|
@ -498,8 +485,7 @@ func TestDirRemoveAll(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirRemoveName(t *testing.T) {
|
func TestDirRemoveName(t *testing.T) {
|
||||||
r, vfs, dir, _, cleanup := dirCreate(t)
|
r, vfs, dir, _ := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
err := dir.RemoveName("file1")
|
err := dir.RemoveName("file1")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -518,8 +504,7 @@ func TestDirRemoveName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirRename(t *testing.T) {
|
func TestDirRename(t *testing.T) {
|
||||||
r, vfs, dir, file1, cleanup := dirCreate(t)
|
r, vfs, dir, file1 := dirCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
features := r.Fremote.Features()
|
features := r.Fremote.Features()
|
||||||
if features.DirMove == nil && features.Move == nil && features.Copy == nil {
|
if features.DirMove == nil && features.Move == nil && features.Copy == nil {
|
||||||
|
|
|
@ -17,11 +17,11 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fileCreate(t *testing.T, mode vfscommon.CacheMode) (r *fstest.Run, vfs *VFS, fh *File, item fstest.Item, cleanup func()) {
|
func fileCreate(t *testing.T, mode vfscommon.CacheMode) (r *fstest.Run, vfs *VFS, fh *File, item fstest.Item) {
|
||||||
opt := vfscommon.DefaultOpt
|
opt := vfscommon.DefaultOpt
|
||||||
opt.CacheMode = mode
|
opt.CacheMode = mode
|
||||||
opt.WriteBack = writeBackDelay
|
opt.WriteBack = writeBackDelay
|
||||||
r, vfs, cleanup = newTestVFSOpt(t, &opt)
|
r, vfs = newTestVFSOpt(t, &opt)
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "dir/file1", "file1 contents", t1)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
@ -30,12 +30,11 @@ func fileCreate(t *testing.T, mode vfscommon.CacheMode) (r *fstest.Run, vfs *VFS
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, node.Mode().IsRegular())
|
require.True(t, node.Mode().IsRegular())
|
||||||
|
|
||||||
return r, vfs, node.(*File), file1, cleanup
|
return r, vfs, node.(*File), file1
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileMethods(t *testing.T) {
|
func TestFileMethods(t *testing.T) {
|
||||||
r, vfs, file, _, cleanup := fileCreate(t, vfscommon.CacheModeOff)
|
r, vfs, file, _ := fileCreate(t, vfscommon.CacheModeOff)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// String
|
// String
|
||||||
assert.Equal(t, "dir/file1", file.String())
|
assert.Equal(t, "dir/file1", file.String())
|
||||||
|
@ -92,8 +91,7 @@ func testFileSetModTime(t *testing.T, cacheMode vfscommon.CacheMode, open bool,
|
||||||
if !canSetModTimeValue {
|
if !canSetModTimeValue {
|
||||||
t.Skip("can't set mod time")
|
t.Skip("can't set mod time")
|
||||||
}
|
}
|
||||||
r, vfs, file, file1, cleanup := fileCreate(t, cacheMode)
|
r, vfs, file, file1 := fileCreate(t, cacheMode)
|
||||||
defer cleanup()
|
|
||||||
if !canSetModTime(t, r) {
|
if !canSetModTime(t, r) {
|
||||||
t.Skip("can't set mod time")
|
t.Skip("can't set mod time")
|
||||||
}
|
}
|
||||||
|
@ -176,8 +174,7 @@ func fileCheckContents(t *testing.T, file *File) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileOpenRead(t *testing.T) {
|
func TestFileOpenRead(t *testing.T) {
|
||||||
_, _, file, _, cleanup := fileCreate(t, vfscommon.CacheModeOff)
|
_, _, file, _ := fileCreate(t, vfscommon.CacheModeOff)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
fileCheckContents(t, file)
|
fileCheckContents(t, file)
|
||||||
}
|
}
|
||||||
|
@ -229,8 +226,7 @@ func TestFileOpenReadUnknownSize(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileOpenWrite(t *testing.T) {
|
func TestFileOpenWrite(t *testing.T) {
|
||||||
_, vfs, file, _, cleanup := fileCreate(t, vfscommon.CacheModeOff)
|
_, vfs, file, _ := fileCreate(t, vfscommon.CacheModeOff)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
fd, err := file.openWrite(os.O_WRONLY | os.O_TRUNC)
|
fd, err := file.openWrite(os.O_WRONLY | os.O_TRUNC)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -249,8 +245,7 @@ func TestFileOpenWrite(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileRemove(t *testing.T) {
|
func TestFileRemove(t *testing.T) {
|
||||||
r, vfs, file, _, cleanup := fileCreate(t, vfscommon.CacheModeOff)
|
r, vfs, file, _ := fileCreate(t, vfscommon.CacheModeOff)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
err := file.Remove()
|
err := file.Remove()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -263,8 +258,7 @@ func TestFileRemove(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileRemoveAll(t *testing.T) {
|
func TestFileRemoveAll(t *testing.T) {
|
||||||
r, vfs, file, _, cleanup := fileCreate(t, vfscommon.CacheModeOff)
|
r, vfs, file, _ := fileCreate(t, vfscommon.CacheModeOff)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
err := file.RemoveAll()
|
err := file.RemoveAll()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -277,8 +271,7 @@ func TestFileRemoveAll(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileOpen(t *testing.T) {
|
func TestFileOpen(t *testing.T) {
|
||||||
_, _, file, _, cleanup := fileCreate(t, vfscommon.CacheModeOff)
|
_, _, file, _ := fileCreate(t, vfscommon.CacheModeOff)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
fd, err := file.Open(os.O_RDONLY)
|
fd, err := file.Open(os.O_RDONLY)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -303,8 +296,7 @@ func TestFileOpen(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFileRename(t *testing.T, mode vfscommon.CacheMode, inCache bool, forceCache bool) {
|
func testFileRename(t *testing.T, mode vfscommon.CacheMode, inCache bool, forceCache bool) {
|
||||||
r, vfs, file, item, cleanup := fileCreate(t, mode)
|
r, vfs, file, item := fileCreate(t, mode)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
if !operations.CanServerSideMove(r.Fremote) {
|
if !operations.CanServerSideMove(r.Fremote) {
|
||||||
t.Skip("skip as can't rename files")
|
t.Skip("skip as can't rename files")
|
||||||
|
|
|
@ -12,14 +12,14 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func rcNewRun(t *testing.T, method string) (r *fstest.Run, vfs *VFS, cleanup func(), call *rc.Call) {
|
func rcNewRun(t *testing.T, method string) (r *fstest.Run, vfs *VFS, call *rc.Call) {
|
||||||
if *fstest.RemoteName != "" {
|
if *fstest.RemoteName != "" {
|
||||||
t.Skip("Skipping test on non local remote")
|
t.Skip("Skipping test on non local remote")
|
||||||
}
|
}
|
||||||
r, vfs, cleanup = newTestVFS(t)
|
r, vfs = newTestVFS(t)
|
||||||
call = rc.Calls.Get(method)
|
call = rc.Calls.Get(method)
|
||||||
assert.NotNil(t, call)
|
assert.NotNil(t, call)
|
||||||
return r, vfs, cleanup, call
|
return r, vfs, call
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRcGetVFS(t *testing.T) {
|
func TestRcGetVFS(t *testing.T) {
|
||||||
|
@ -29,8 +29,7 @@ func TestRcGetVFS(t *testing.T) {
|
||||||
assert.Contains(t, err.Error(), "no VFS active")
|
assert.Contains(t, err.Error(), "no VFS active")
|
||||||
assert.Nil(t, vfs)
|
assert.Nil(t, vfs)
|
||||||
|
|
||||||
r, vfs2, cleanup := newTestVFS(t)
|
r, vfs2 := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
vfs, err = getVFS(in)
|
vfs, err = getVFS(in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -65,8 +64,7 @@ func TestRcGetVFS(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRcForget(t *testing.T) {
|
func TestRcForget(t *testing.T) {
|
||||||
r, vfs, cleanup, call := rcNewRun(t, "vfs/forget")
|
r, vfs, call := rcNewRun(t, "vfs/forget")
|
||||||
defer cleanup()
|
|
||||||
_, _ = r, vfs
|
_, _ = r, vfs
|
||||||
in := rc.Params{"fs": fs.ConfigString(r.Fremote)}
|
in := rc.Params{"fs": fs.ConfigString(r.Fremote)}
|
||||||
out, err := call.Fn(context.Background(), in)
|
out, err := call.Fn(context.Background(), in)
|
||||||
|
@ -78,8 +76,7 @@ func TestRcForget(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRcRefresh(t *testing.T) {
|
func TestRcRefresh(t *testing.T) {
|
||||||
r, vfs, cleanup, call := rcNewRun(t, "vfs/refresh")
|
r, vfs, call := rcNewRun(t, "vfs/refresh")
|
||||||
defer cleanup()
|
|
||||||
_, _ = r, vfs
|
_, _ = r, vfs
|
||||||
in := rc.Params{"fs": fs.ConfigString(r.Fremote)}
|
in := rc.Params{"fs": fs.ConfigString(r.Fremote)}
|
||||||
out, err := call.Fn(context.Background(), in)
|
out, err := call.Fn(context.Background(), in)
|
||||||
|
@ -93,8 +90,7 @@ func TestRcRefresh(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRcPollInterval(t *testing.T) {
|
func TestRcPollInterval(t *testing.T) {
|
||||||
r, vfs, cleanup, call := rcNewRun(t, "vfs/poll-interval")
|
r, vfs, call := rcNewRun(t, "vfs/poll-interval")
|
||||||
defer cleanup()
|
|
||||||
_ = vfs
|
_ = vfs
|
||||||
if r.Fremote.Features().ChangeNotify == nil {
|
if r.Fremote.Features().ChangeNotify == nil {
|
||||||
t.Skip("ChangeNotify not supported")
|
t.Skip("ChangeNotify not supported")
|
||||||
|
@ -106,8 +102,7 @@ func TestRcPollInterval(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRcList(t *testing.T) {
|
func TestRcList(t *testing.T) {
|
||||||
r, vfs, cleanup, call := rcNewRun(t, "vfs/list")
|
r, vfs, call := rcNewRun(t, "vfs/list")
|
||||||
defer cleanup()
|
|
||||||
_ = vfs
|
_ = vfs
|
||||||
|
|
||||||
out, err := call.Fn(context.Background(), nil)
|
out, err := call.Fn(context.Background(), nil)
|
||||||
|
@ -121,8 +116,7 @@ func TestRcList(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRcStats(t *testing.T) {
|
func TestRcStats(t *testing.T) {
|
||||||
r, vfs, cleanup, call := rcNewRun(t, "vfs/stats")
|
r, vfs, call := rcNewRun(t, "vfs/stats")
|
||||||
defer cleanup()
|
|
||||||
out, err := call.Fn(context.Background(), nil)
|
out, err := call.Fn(context.Background(), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, fs.ConfigString(r.Fremote), out["fs"])
|
assert.Equal(t, fs.ConfigString(r.Fremote), out["fs"])
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Open a file for write
|
// Open a file for write
|
||||||
func readHandleCreate(t *testing.T) (r *fstest.Run, vfs *VFS, fh *ReadFileHandle, cleanup func()) {
|
func readHandleCreate(t *testing.T) (r *fstest.Run, vfs *VFS, fh *ReadFileHandle) {
|
||||||
r, vfs, cleanup = newTestVFS(t)
|
r, vfs = newTestVFS(t)
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "dir/file1", "0123456789abcdef", t1)
|
file1 := r.WriteObject(context.Background(), "dir/file1", "0123456789abcdef", t1)
|
||||||
r.CheckRemoteItems(t, file1)
|
r.CheckRemoteItems(t, file1)
|
||||||
|
@ -23,7 +23,7 @@ func readHandleCreate(t *testing.T) (r *fstest.Run, vfs *VFS, fh *ReadFileHandle
|
||||||
fh, ok := h.(*ReadFileHandle)
|
fh, ok := h.(*ReadFileHandle)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
return r, vfs, fh, cleanup
|
return r, vfs, fh
|
||||||
}
|
}
|
||||||
|
|
||||||
// read data from the string
|
// read data from the string
|
||||||
|
@ -37,8 +37,7 @@ func readString(t *testing.T, fh *ReadFileHandle, n int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadFileHandleMethods(t *testing.T) {
|
func TestReadFileHandleMethods(t *testing.T) {
|
||||||
_, _, fh, cleanup := readHandleCreate(t)
|
_, _, fh := readHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// String
|
// String
|
||||||
assert.Equal(t, "dir/file1 (r)", fh.String())
|
assert.Equal(t, "dir/file1 (r)", fh.String())
|
||||||
|
@ -80,8 +79,7 @@ func TestReadFileHandleMethods(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadFileHandleSeek(t *testing.T) {
|
func TestReadFileHandleSeek(t *testing.T) {
|
||||||
_, _, fh, cleanup := readHandleCreate(t)
|
_, _, fh := readHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, "0", readString(t, fh, 1))
|
assert.Equal(t, "0", readString(t, fh, 1))
|
||||||
|
|
||||||
|
@ -123,8 +121,7 @@ func TestReadFileHandleSeek(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadFileHandleReadAt(t *testing.T) {
|
func TestReadFileHandleReadAt(t *testing.T) {
|
||||||
_, _, fh, cleanup := readHandleCreate(t)
|
_, _, fh := readHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// read from start
|
// read from start
|
||||||
buf := make([]byte, 1)
|
buf := make([]byte, 1)
|
||||||
|
@ -179,8 +176,7 @@ func TestReadFileHandleReadAt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadFileHandleFlush(t *testing.T) {
|
func TestReadFileHandleFlush(t *testing.T) {
|
||||||
_, _, fh, cleanup := readHandleCreate(t)
|
_, _, fh := readHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Check Flush does nothing if read not called
|
// Check Flush does nothing if read not called
|
||||||
err := fh.Flush()
|
err := fh.Flush()
|
||||||
|
@ -208,8 +204,7 @@ func TestReadFileHandleFlush(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadFileHandleRelease(t *testing.T) {
|
func TestReadFileHandleRelease(t *testing.T) {
|
||||||
_, _, fh, cleanup := readHandleCreate(t)
|
_, _, fh := readHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Check Release does nothing if file not read from
|
// Check Release does nothing if file not read from
|
||||||
err := fh.Release()
|
err := fh.Release()
|
||||||
|
|
|
@ -29,11 +29,11 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a file and open it with the flags passed in
|
// Create a file and open it with the flags passed in
|
||||||
func rwHandleCreateFlags(t *testing.T, create bool, filename string, flags int) (r *fstest.Run, vfs *VFS, fh *RWFileHandle, cleanup func()) {
|
func rwHandleCreateFlags(t *testing.T, create bool, filename string, flags int) (r *fstest.Run, vfs *VFS, fh *RWFileHandle) {
|
||||||
opt := vfscommon.DefaultOpt
|
opt := vfscommon.DefaultOpt
|
||||||
opt.CacheMode = vfscommon.CacheModeFull
|
opt.CacheMode = vfscommon.CacheModeFull
|
||||||
opt.WriteBack = writeBackDelay
|
opt.WriteBack = writeBackDelay
|
||||||
r, vfs, cleanup = newTestVFSOpt(t, &opt)
|
r, vfs = newTestVFSOpt(t, &opt)
|
||||||
|
|
||||||
if create {
|
if create {
|
||||||
file1 := r.WriteObject(context.Background(), filename, "0123456789abcdef", t1)
|
file1 := r.WriteObject(context.Background(), filename, "0123456789abcdef", t1)
|
||||||
|
@ -45,16 +45,16 @@ func rwHandleCreateFlags(t *testing.T, create bool, filename string, flags int)
|
||||||
fh, ok := h.(*RWFileHandle)
|
fh, ok := h.(*RWFileHandle)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
return r, vfs, fh, cleanup
|
return r, vfs, fh
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open a file for read
|
// Open a file for read
|
||||||
func rwHandleCreateReadOnly(t *testing.T) (r *fstest.Run, vfs *VFS, fh *RWFileHandle, cleanup func()) {
|
func rwHandleCreateReadOnly(t *testing.T) (r *fstest.Run, vfs *VFS, fh *RWFileHandle) {
|
||||||
return rwHandleCreateFlags(t, true, "dir/file1", os.O_RDONLY)
|
return rwHandleCreateFlags(t, true, "dir/file1", os.O_RDONLY)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open a file for write
|
// Open a file for write
|
||||||
func rwHandleCreateWriteOnly(t *testing.T) (r *fstest.Run, vfs *VFS, fh *RWFileHandle, cleanup func()) {
|
func rwHandleCreateWriteOnly(t *testing.T) (r *fstest.Run, vfs *VFS, fh *RWFileHandle) {
|
||||||
return rwHandleCreateFlags(t, false, "file1", os.O_WRONLY|os.O_CREATE)
|
return rwHandleCreateFlags(t, false, "file1", os.O_WRONLY|os.O_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,7 @@ func rwReadString(t *testing.T, fh *RWFileHandle, n int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleMethodsRead(t *testing.T) {
|
func TestRWFileHandleMethodsRead(t *testing.T) {
|
||||||
_, _, fh, cleanup := rwHandleCreateReadOnly(t)
|
_, _, fh := rwHandleCreateReadOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// String
|
// String
|
||||||
assert.Equal(t, "dir/file1 (rw)", fh.String())
|
assert.Equal(t, "dir/file1 (rw)", fh.String())
|
||||||
|
@ -116,8 +115,7 @@ func TestRWFileHandleMethodsRead(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleSeek(t *testing.T) {
|
func TestRWFileHandleSeek(t *testing.T) {
|
||||||
_, _, fh, cleanup := rwHandleCreateReadOnly(t)
|
_, _, fh := rwHandleCreateReadOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, fh.opened, false)
|
assert.Equal(t, fh.opened, false)
|
||||||
|
|
||||||
|
@ -166,8 +164,7 @@ func TestRWFileHandleSeek(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleReadAt(t *testing.T) {
|
func TestRWFileHandleReadAt(t *testing.T) {
|
||||||
_, _, fh, cleanup := rwHandleCreateReadOnly(t)
|
_, _, fh := rwHandleCreateReadOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// read from start
|
// read from start
|
||||||
buf := make([]byte, 1)
|
buf := make([]byte, 1)
|
||||||
|
@ -216,8 +213,7 @@ func TestRWFileHandleReadAt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleFlushRead(t *testing.T) {
|
func TestRWFileHandleFlushRead(t *testing.T) {
|
||||||
_, _, fh, cleanup := rwHandleCreateReadOnly(t)
|
_, _, fh := rwHandleCreateReadOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Check Flush does nothing if read not called
|
// Check Flush does nothing if read not called
|
||||||
err := fh.Flush()
|
err := fh.Flush()
|
||||||
|
@ -245,8 +241,7 @@ func TestRWFileHandleFlushRead(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleReleaseRead(t *testing.T) {
|
func TestRWFileHandleReleaseRead(t *testing.T) {
|
||||||
_, _, fh, cleanup := rwHandleCreateReadOnly(t)
|
_, _, fh := rwHandleCreateReadOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Read data
|
// Read data
|
||||||
buf := make([]byte, 256)
|
buf := make([]byte, 256)
|
||||||
|
@ -268,8 +263,7 @@ func TestRWFileHandleReleaseRead(t *testing.T) {
|
||||||
/// ------------------------------------------------------------
|
/// ------------------------------------------------------------
|
||||||
|
|
||||||
func TestRWFileHandleMethodsWrite(t *testing.T) {
|
func TestRWFileHandleMethodsWrite(t *testing.T) {
|
||||||
r, vfs, fh, cleanup := rwHandleCreateWriteOnly(t)
|
r, vfs, fh := rwHandleCreateWriteOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// String
|
// String
|
||||||
assert.Equal(t, "file1 (rw)", fh.String())
|
assert.Equal(t, "file1 (rw)", fh.String())
|
||||||
|
@ -344,8 +338,7 @@ func TestRWFileHandleMethodsWrite(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleWriteAt(t *testing.T) {
|
func TestRWFileHandleWriteAt(t *testing.T) {
|
||||||
r, vfs, fh, cleanup := rwHandleCreateWriteOnly(t)
|
r, vfs, fh := rwHandleCreateWriteOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
offset := func() int64 {
|
offset := func() int64 {
|
||||||
n, err := fh.Seek(0, io.SeekCurrent)
|
n, err := fh.Seek(0, io.SeekCurrent)
|
||||||
|
@ -392,8 +385,7 @@ func TestRWFileHandleWriteAt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleWriteNoWrite(t *testing.T) {
|
func TestRWFileHandleWriteNoWrite(t *testing.T) {
|
||||||
r, vfs, fh, cleanup := rwHandleCreateWriteOnly(t)
|
r, vfs, fh := rwHandleCreateWriteOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Close the file without writing to it
|
// Close the file without writing to it
|
||||||
err := fh.Close()
|
err := fh.Close()
|
||||||
|
@ -426,8 +418,7 @@ func TestRWFileHandleWriteNoWrite(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleFlushWrite(t *testing.T) {
|
func TestRWFileHandleFlushWrite(t *testing.T) {
|
||||||
_, _, fh, cleanup := rwHandleCreateWriteOnly(t)
|
_, _, fh := rwHandleCreateWriteOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Check that the file has been create and is open
|
// Check that the file has been create and is open
|
||||||
assert.True(t, fh.opened)
|
assert.True(t, fh.opened)
|
||||||
|
@ -455,8 +446,7 @@ func TestRWFileHandleFlushWrite(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleReleaseWrite(t *testing.T) {
|
func TestRWFileHandleReleaseWrite(t *testing.T) {
|
||||||
_, _, fh, cleanup := rwHandleCreateWriteOnly(t)
|
_, _, fh := rwHandleCreateWriteOnly(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Write some data
|
// Write some data
|
||||||
n, err := fh.Write([]byte("hello"))
|
n, err := fh.Write([]byte("hello"))
|
||||||
|
@ -485,8 +475,7 @@ func assertSize(t *testing.T, vfs *VFS, fh *RWFileHandle, filepath string, size
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleSizeTruncateExisting(t *testing.T) {
|
func TestRWFileHandleSizeTruncateExisting(t *testing.T) {
|
||||||
_, vfs, fh, cleanup := rwHandleCreateFlags(t, true, "dir/file1", os.O_WRONLY|os.O_TRUNC)
|
_, vfs, fh := rwHandleCreateFlags(t, true, "dir/file1", os.O_WRONLY|os.O_TRUNC)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// check initial size after opening
|
// check initial size after opening
|
||||||
assertSize(t, vfs, fh, "dir/file1", 0)
|
assertSize(t, vfs, fh, "dir/file1", 0)
|
||||||
|
@ -507,8 +496,7 @@ func TestRWFileHandleSizeTruncateExisting(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleSizeCreateExisting(t *testing.T) {
|
func TestRWFileHandleSizeCreateExisting(t *testing.T) {
|
||||||
_, vfs, fh, cleanup := rwHandleCreateFlags(t, true, "dir/file1", os.O_WRONLY|os.O_CREATE)
|
_, vfs, fh := rwHandleCreateFlags(t, true, "dir/file1", os.O_WRONLY|os.O_CREATE)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// check initial size after opening
|
// check initial size after opening
|
||||||
assertSize(t, vfs, fh, "dir/file1", 16)
|
assertSize(t, vfs, fh, "dir/file1", 16)
|
||||||
|
@ -537,8 +525,7 @@ func TestRWFileHandleSizeCreateExisting(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRWFileHandleSizeCreateNew(t *testing.T) {
|
func TestRWFileHandleSizeCreateNew(t *testing.T) {
|
||||||
_, vfs, fh, cleanup := rwHandleCreateFlags(t, false, "file1", os.O_WRONLY|os.O_CREATE)
|
_, vfs, fh := rwHandleCreateFlags(t, false, "file1", os.O_WRONLY|os.O_CREATE)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// check initial size after opening
|
// check initial size after opening
|
||||||
assertSize(t, vfs, fh, "file1", 0)
|
assertSize(t, vfs, fh, "file1", 0)
|
||||||
|
@ -647,8 +634,7 @@ func TestRWFileHandleOpenTests(t *testing.T) {
|
||||||
opt := vfscommon.DefaultOpt
|
opt := vfscommon.DefaultOpt
|
||||||
opt.CacheMode = cacheMode
|
opt.CacheMode = cacheMode
|
||||||
opt.WriteBack = writeBackDelay
|
opt.WriteBack = writeBackDelay
|
||||||
_, vfs, cleanup := newTestVFSOpt(t, &opt)
|
_, vfs := newTestVFSOpt(t, &opt)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
for _, test := range openTests {
|
for _, test := range openTests {
|
||||||
t.Run(test.what, func(t *testing.T) {
|
t.Run(test.what, func(t *testing.T) {
|
||||||
|
@ -661,8 +647,7 @@ func TestRWFileHandleOpenTests(t *testing.T) {
|
||||||
|
|
||||||
// tests mod time on open files
|
// tests mod time on open files
|
||||||
func TestRWFileModTimeWithOpenWriters(t *testing.T) {
|
func TestRWFileModTimeWithOpenWriters(t *testing.T) {
|
||||||
r, vfs, fh, cleanup := rwHandleCreateWriteOnly(t)
|
r, vfs, fh := rwHandleCreateWriteOnly(t)
|
||||||
defer cleanup()
|
|
||||||
if !canSetModTime(t, r) {
|
if !canSetModTime(t, r) {
|
||||||
t.Skip("can't set mod time")
|
t.Skip("can't set mod time")
|
||||||
}
|
}
|
||||||
|
@ -700,8 +685,7 @@ func TestRWCacheRename(t *testing.T) {
|
||||||
opt := vfscommon.DefaultOpt
|
opt := vfscommon.DefaultOpt
|
||||||
opt.CacheMode = vfscommon.CacheModeFull
|
opt.CacheMode = vfscommon.CacheModeFull
|
||||||
opt.WriteBack = writeBackDelay
|
opt.WriteBack = writeBackDelay
|
||||||
r, vfs, cleanup := newTestVFSOpt(t, &opt)
|
r, vfs := newTestVFSOpt(t, &opt)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
if !operations.CanServerSideMove(r.Fremote) {
|
if !operations.CanServerSideMove(r.Fremote) {
|
||||||
t.Skip("skip as can't rename files")
|
t.Skip("skip as can't rename files")
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
|
|
||||||
func TestCaseSensitivity(t *testing.T) {
|
func TestCaseSensitivity(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
if r.Fremote.Features().CaseInsensitive {
|
if r.Fremote.Features().CaseInsensitive {
|
||||||
t.Skip("Can't test case sensitivity - this remote is officially not case-sensitive")
|
t.Skip("Can't test case sensitivity - this remote is officially not case-sensitive")
|
||||||
|
|
|
@ -46,18 +46,17 @@ func cleanupVFS(t *testing.T, vfs *VFS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new VFS
|
// Create a new VFS
|
||||||
func newTestVFSOpt(t *testing.T, opt *vfscommon.Options) (r *fstest.Run, vfs *VFS, cleanup func()) {
|
func newTestVFSOpt(t *testing.T, opt *vfscommon.Options) (r *fstest.Run, vfs *VFS) {
|
||||||
r = fstest.NewRun(t)
|
r = fstest.NewRun(t)
|
||||||
vfs = New(r.Fremote, opt)
|
vfs = New(r.Fremote, opt)
|
||||||
cleanup = func() {
|
t.Cleanup(func() {
|
||||||
cleanupVFS(t, vfs)
|
cleanupVFS(t, vfs)
|
||||||
r.Finalise()
|
})
|
||||||
}
|
return r, vfs
|
||||||
return r, vfs, cleanup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new VFS with default options
|
// Create a new VFS with default options
|
||||||
func newTestVFS(t *testing.T) (r *fstest.Run, vfs *VFS, cleanup func()) {
|
func newTestVFS(t *testing.T) (r *fstest.Run, vfs *VFS) {
|
||||||
return newTestVFSOpt(t, nil)
|
return newTestVFSOpt(t, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +135,7 @@ func TestVFSNew(t *testing.T) {
|
||||||
|
|
||||||
checkActiveCacheEntries(0)
|
checkActiveCacheEntries(0)
|
||||||
|
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
|
|
||||||
// Check making a VFS with nil options
|
// Check making a VFS with nil options
|
||||||
var defaultOpt = vfscommon.DefaultOpt
|
var defaultOpt = vfscommon.DefaultOpt
|
||||||
|
@ -158,7 +157,7 @@ func TestVFSNew(t *testing.T) {
|
||||||
|
|
||||||
checkActiveCacheEntries(1)
|
checkActiveCacheEntries(1)
|
||||||
|
|
||||||
cleanup()
|
cleanupVFS(t, vfs)
|
||||||
|
|
||||||
checkActiveCacheEntries(0)
|
checkActiveCacheEntries(0)
|
||||||
}
|
}
|
||||||
|
@ -169,8 +168,7 @@ func TestVFSNewWithOpts(t *testing.T) {
|
||||||
opt.DirPerms = 0777
|
opt.DirPerms = 0777
|
||||||
opt.FilePerms = 0666
|
opt.FilePerms = 0666
|
||||||
opt.Umask = 0002
|
opt.Umask = 0002
|
||||||
_, vfs, cleanup := newTestVFSOpt(t, &opt)
|
_, vfs := newTestVFSOpt(t, &opt)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, os.FileMode(0775)|os.ModeDir, vfs.Opt.DirPerms)
|
assert.Equal(t, os.FileMode(0775)|os.ModeDir, vfs.Opt.DirPerms)
|
||||||
assert.Equal(t, os.FileMode(0664), vfs.Opt.FilePerms)
|
assert.Equal(t, os.FileMode(0664), vfs.Opt.FilePerms)
|
||||||
|
@ -178,8 +176,7 @@ func TestVFSNewWithOpts(t *testing.T) {
|
||||||
|
|
||||||
// TestRoot checks root directory is present and correct
|
// TestRoot checks root directory is present and correct
|
||||||
func TestVFSRoot(t *testing.T) {
|
func TestVFSRoot(t *testing.T) {
|
||||||
_, vfs, cleanup := newTestVFS(t)
|
_, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
root, err := vfs.Root()
|
root, err := vfs.Root()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -189,8 +186,7 @@ func TestVFSRoot(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVFSStat(t *testing.T) {
|
func TestVFSStat(t *testing.T) {
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
|
||||||
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
|
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
|
||||||
|
@ -225,8 +221,7 @@ func TestVFSStat(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVFSStatParent(t *testing.T) {
|
func TestVFSStatParent(t *testing.T) {
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
|
||||||
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
|
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
|
||||||
|
@ -258,8 +253,7 @@ func TestVFSStatParent(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVFSOpenFile(t *testing.T) {
|
func TestVFSOpenFile(t *testing.T) {
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
|
file1 := r.WriteObject(context.Background(), "file1", "file1 contents", t1)
|
||||||
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
|
file2 := r.WriteObject(context.Background(), "dir/file2", "file2 contents", t2)
|
||||||
|
@ -293,8 +287,7 @@ func TestVFSOpenFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVFSRename(t *testing.T) {
|
func TestVFSRename(t *testing.T) {
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
features := r.Fremote.Features()
|
features := r.Fremote.Features()
|
||||||
if features.Move == nil && features.Copy == nil {
|
if features.Move == nil && features.Copy == nil {
|
||||||
|
@ -322,8 +315,7 @@ func TestVFSRename(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVFSStatfs(t *testing.T) {
|
func TestVFSStatfs(t *testing.T) {
|
||||||
r, vfs, cleanup := newTestVFS(t)
|
r, vfs := newTestVFS(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// pre-conditions
|
// pre-conditions
|
||||||
assert.Nil(t, vfs.usage)
|
assert.Nil(t, vfs.usage)
|
||||||
|
|
|
@ -81,7 +81,7 @@ func addVirtual(remote string, size int64, isDir bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestCacheOpt(t *testing.T, opt vfscommon.Options) (r *fstest.Run, c *Cache, cleanup func()) {
|
func newTestCacheOpt(t *testing.T, opt vfscommon.Options) (r *fstest.Run, c *Cache) {
|
||||||
r = fstest.NewRun(t)
|
r = fstest.NewRun(t)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
@ -90,18 +90,17 @@ func newTestCacheOpt(t *testing.T, opt vfscommon.Options) (r *fstest.Run, c *Cac
|
||||||
c, err := New(ctx, r.Fremote, &opt, addVirtual)
|
c, err := New(ctx, r.Fremote, &opt, addVirtual)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cleanup = func() {
|
t.Cleanup(func() {
|
||||||
err := c.CleanUp()
|
err := c.CleanUp()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assertPathNotExist(t, c.root)
|
assertPathNotExist(t, c.root)
|
||||||
cancel()
|
cancel()
|
||||||
r.Finalise()
|
})
|
||||||
}
|
|
||||||
|
|
||||||
return r, c, cleanup
|
return r, c
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestCache(t *testing.T) (r *fstest.Run, c *Cache, cleanup func()) {
|
func newTestCache(t *testing.T) (r *fstest.Run, c *Cache) {
|
||||||
opt := vfscommon.DefaultOpt
|
opt := vfscommon.DefaultOpt
|
||||||
|
|
||||||
// Disable the cache cleaner as it interferes with these tests
|
// Disable the cache cleaner as it interferes with these tests
|
||||||
|
@ -114,8 +113,7 @@ func newTestCache(t *testing.T) (r *fstest.Run, c *Cache, cleanup func()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheNew(t *testing.T) {
|
func TestCacheNew(t *testing.T) {
|
||||||
r, c, cleanup := newTestCache(t)
|
r, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Contains(t, c.root, "vfs")
|
assert.Contains(t, c.root, "vfs")
|
||||||
assert.Contains(t, c.fcache.Root(), filepath.Base(r.Fremote.Root()))
|
assert.Contains(t, c.fcache.Root(), filepath.Base(r.Fremote.Root()))
|
||||||
|
@ -191,8 +189,7 @@ func TestCacheNew(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheOpens(t *testing.T) {
|
func TestCacheOpens(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, []string(nil), itemAsString(c))
|
assert.Equal(t, []string(nil), itemAsString(c))
|
||||||
potato := c.Item("potato")
|
potato := c.Item("potato")
|
||||||
|
@ -240,8 +237,7 @@ func TestCacheOpens(t *testing.T) {
|
||||||
|
|
||||||
// test the open, createItemDir, purge, close, purge sequence
|
// test the open, createItemDir, purge, close, purge sequence
|
||||||
func TestCacheOpenMkdir(t *testing.T) {
|
func TestCacheOpenMkdir(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// open
|
// open
|
||||||
potato := c.Item("sub/potato")
|
potato := c.Item("sub/potato")
|
||||||
|
@ -288,8 +284,7 @@ func TestCacheOpenMkdir(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCachePurgeOld(t *testing.T) {
|
func TestCachePurgeOld(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Test funcs
|
// Test funcs
|
||||||
c.purgeOld(-10 * time.Second)
|
c.purgeOld(-10 * time.Second)
|
||||||
|
@ -342,8 +337,7 @@ func TestCachePurgeOld(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCachePurgeOverQuota(t *testing.T) {
|
func TestCachePurgeOverQuota(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Test funcs
|
// Test funcs
|
||||||
|
|
||||||
|
@ -428,8 +422,7 @@ func TestCachePurgeOverQuota(t *testing.T) {
|
||||||
|
|
||||||
// test reset clean files
|
// test reset clean files
|
||||||
func TestCachePurgeClean(t *testing.T) {
|
func TestCachePurgeClean(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
contents, obj, potato1 := newFile(t, r, c, "existing")
|
contents, obj, potato1 := newFile(t, r, c, "existing")
|
||||||
_ = contents
|
_ = contents
|
||||||
|
|
||||||
|
@ -491,8 +484,7 @@ func TestCachePurgeClean(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheInUse(t *testing.T) {
|
func TestCacheInUse(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.False(t, c.InUse("potato"))
|
assert.False(t, c.InUse("potato"))
|
||||||
|
|
||||||
|
@ -510,8 +502,7 @@ func TestCacheInUse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheDirtyItem(t *testing.T) {
|
func TestCacheDirtyItem(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Nil(t, c.DirtyItem("potato"))
|
assert.Nil(t, c.DirtyItem("potato"))
|
||||||
|
|
||||||
|
@ -530,8 +521,7 @@ func TestCacheDirtyItem(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheExistsAndRemove(t *testing.T) {
|
func TestCacheExistsAndRemove(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.False(t, c.Exists("potato"))
|
assert.False(t, c.Exists("potato"))
|
||||||
|
|
||||||
|
@ -554,8 +544,7 @@ func TestCacheExistsAndRemove(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheRename(t *testing.T) {
|
func TestCacheRename(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
|
|
||||||
|
@ -611,8 +600,7 @@ func TestCacheCleaner(t *testing.T) {
|
||||||
opt := vfscommon.DefaultOpt
|
opt := vfscommon.DefaultOpt
|
||||||
opt.CachePollInterval = 10 * time.Millisecond
|
opt.CachePollInterval = 10 * time.Millisecond
|
||||||
opt.CacheMaxAge = 20 * time.Millisecond
|
opt.CacheMaxAge = 20 * time.Millisecond
|
||||||
_, c, cleanup := newTestCacheOpt(t, opt)
|
_, c := newTestCacheOpt(t, opt)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
time.Sleep(2 * opt.CachePollInterval)
|
time.Sleep(2 * opt.CachePollInterval)
|
||||||
|
|
||||||
|
@ -634,8 +622,7 @@ func TestCacheCleaner(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheSetModTime(t *testing.T) {
|
func TestCacheSetModTime(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
t1 := time.Date(2010, 1, 2, 3, 4, 5, 9, time.UTC)
|
t1 := time.Date(2010, 1, 2, 3, 4, 5, 9, time.UTC)
|
||||||
|
|
||||||
|
@ -653,8 +640,7 @@ func TestCacheSetModTime(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheTotaInUse(t *testing.T) {
|
func TestCacheTotaInUse(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
assert.Equal(t, int(0), c.TotalInUse())
|
assert.Equal(t, int(0), c.TotalInUse())
|
||||||
|
|
||||||
|
@ -681,8 +667,7 @@ func TestCacheTotaInUse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheDump(t *testing.T) {
|
func TestCacheDump(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
out := (*Cache)(nil).Dump()
|
out := (*Cache)(nil).Dump()
|
||||||
assert.Equal(t, "Cache: <nil>\n", out)
|
assert.Equal(t, "Cache: <nil>\n", out)
|
||||||
|
@ -703,8 +688,7 @@ func TestCacheDump(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheStats(t *testing.T) {
|
func TestCacheStats(t *testing.T) {
|
||||||
_, c, cleanup := newTestCache(t)
|
_, c := newTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
out := c.Stats()
|
out := c.Stats()
|
||||||
assert.Equal(t, int64(0), out["bytesUsed"])
|
assert.Equal(t, int64(0), out["bytesUsed"])
|
||||||
|
|
|
@ -75,7 +75,6 @@ func (item *testItem) WriteAtNoOverwrite(b []byte, off int64) (n int, skipped in
|
||||||
|
|
||||||
func TestDownloaders(t *testing.T) {
|
func TestDownloaders(t *testing.T) {
|
||||||
r := fstest.NewRun(t)
|
r := fstest.NewRun(t)
|
||||||
defer r.Finalise()
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = context.Background()
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
|
|
||||||
var zeroes = string(make([]byte, 100))
|
var zeroes = string(make([]byte, 100))
|
||||||
|
|
||||||
func newItemTestCache(t *testing.T) (r *fstest.Run, c *Cache, cleanup func()) {
|
func newItemTestCache(t *testing.T) (r *fstest.Run, c *Cache) {
|
||||||
opt := vfscommon.DefaultOpt
|
opt := vfscommon.DefaultOpt
|
||||||
|
|
||||||
// Disable the cache cleaner as it interferes with these tests
|
// Disable the cache cleaner as it interferes with these tests
|
||||||
|
@ -61,8 +61,7 @@ func newFile(t *testing.T, r *fstest.Run, c *Cache, remote string) (contents str
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemExists(t *testing.T) {
|
func TestItemExists(t *testing.T) {
|
||||||
_, c, cleanup := newItemTestCache(t)
|
_, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
item, _ := c.get("potato")
|
item, _ := c.get("potato")
|
||||||
|
|
||||||
assert.False(t, item.Exists())
|
assert.False(t, item.Exists())
|
||||||
|
@ -75,8 +74,7 @@ func TestItemExists(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemGetSize(t *testing.T) {
|
func TestItemGetSize(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
item, _ := c.get("potato")
|
item, _ := c.get("potato")
|
||||||
require.NoError(t, item.Open(nil))
|
require.NoError(t, item.Open(nil))
|
||||||
|
|
||||||
|
@ -97,8 +95,7 @@ func TestItemGetSize(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemDirty(t *testing.T) {
|
func TestItemDirty(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
item, _ := c.get("potato")
|
item, _ := c.get("potato")
|
||||||
require.NoError(t, item.Open(nil))
|
require.NoError(t, item.Open(nil))
|
||||||
|
|
||||||
|
@ -122,8 +119,7 @@ func TestItemDirty(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemSync(t *testing.T) {
|
func TestItemSync(t *testing.T) {
|
||||||
_, c, cleanup := newItemTestCache(t)
|
_, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
item, _ := c.get("potato")
|
item, _ := c.get("potato")
|
||||||
|
|
||||||
require.Error(t, item.Sync())
|
require.Error(t, item.Sync())
|
||||||
|
@ -136,8 +132,7 @@ func TestItemSync(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemTruncateNew(t *testing.T) {
|
func TestItemTruncateNew(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
item, _ := c.get("potato")
|
item, _ := c.get("potato")
|
||||||
|
|
||||||
require.Error(t, item.Truncate(0))
|
require.Error(t, item.Truncate(0))
|
||||||
|
@ -164,8 +159,7 @@ func TestItemTruncateNew(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemTruncateExisting(t *testing.T) {
|
func TestItemTruncateExisting(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents, obj, item := newFile(t, r, c, "existing")
|
contents, obj, item := newFile(t, r, c, "existing")
|
||||||
|
|
||||||
|
@ -184,8 +178,7 @@ func TestItemTruncateExisting(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemReadAt(t *testing.T) {
|
func TestItemReadAt(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents, obj, item := newFile(t, r, c, "existing")
|
contents, obj, item := newFile(t, r, c, "existing")
|
||||||
buf := make([]byte, 10)
|
buf := make([]byte, 10)
|
||||||
|
@ -219,8 +212,7 @@ func TestItemReadAt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemWriteAtNew(t *testing.T) {
|
func TestItemWriteAtNew(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
item, _ := c.get("potato")
|
item, _ := c.get("potato")
|
||||||
buf := make([]byte, 10)
|
buf := make([]byte, 10)
|
||||||
|
|
||||||
|
@ -251,8 +243,7 @@ func TestItemWriteAtNew(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemWriteAtExisting(t *testing.T) {
|
func TestItemWriteAtExisting(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents, obj, item := newFile(t, r, c, "existing")
|
contents, obj, item := newFile(t, r, c, "existing")
|
||||||
|
|
||||||
|
@ -276,8 +267,7 @@ func TestItemWriteAtExisting(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemLoadMeta(t *testing.T) {
|
func TestItemLoadMeta(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents, obj, item := newFile(t, r, c, "existing")
|
contents, obj, item := newFile(t, r, c, "existing")
|
||||||
_ = contents
|
_ = contents
|
||||||
|
@ -305,8 +295,7 @@ func TestItemLoadMeta(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemReload(t *testing.T) {
|
func TestItemReload(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents, obj, item := newFile(t, r, c, "existing")
|
contents, obj, item := newFile(t, r, c, "existing")
|
||||||
_ = contents
|
_ = contents
|
||||||
|
@ -350,8 +339,7 @@ func TestItemReload(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemReloadRemoteGone(t *testing.T) {
|
func TestItemReloadRemoteGone(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents, obj, item := newFile(t, r, c, "existing")
|
contents, obj, item := newFile(t, r, c, "existing")
|
||||||
_ = contents
|
_ = contents
|
||||||
|
@ -394,8 +382,7 @@ func TestItemReloadRemoteGone(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemReloadCacheStale(t *testing.T) {
|
func TestItemReloadCacheStale(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents, obj, item := newFile(t, r, c, "existing")
|
contents, obj, item := newFile(t, r, c, "existing")
|
||||||
|
|
||||||
|
@ -450,8 +437,7 @@ func TestItemReloadCacheStale(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestItemReadWrite(t *testing.T) {
|
func TestItemReadWrite(t *testing.T) {
|
||||||
r, c, cleanup := newItemTestCache(t)
|
r, c := newItemTestCache(t)
|
||||||
defer cleanup()
|
|
||||||
const (
|
const (
|
||||||
size = 50*1024*1024 + 123
|
size = 50*1024*1024 + 123
|
||||||
fileName = "large"
|
fileName = "large"
|
||||||
|
|
|
@ -17,20 +17,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Open a file for write
|
// Open a file for write
|
||||||
func writeHandleCreate(t *testing.T) (r *fstest.Run, vfs *VFS, fh *WriteFileHandle, cleanup func()) {
|
func writeHandleCreate(t *testing.T) (r *fstest.Run, vfs *VFS, fh *WriteFileHandle) {
|
||||||
r, vfs, cleanup = newTestVFS(t)
|
r, vfs = newTestVFS(t)
|
||||||
|
|
||||||
h, err := vfs.OpenFile("file1", os.O_WRONLY|os.O_CREATE, 0777)
|
h, err := vfs.OpenFile("file1", os.O_WRONLY|os.O_CREATE, 0777)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
fh, ok := h.(*WriteFileHandle)
|
fh, ok := h.(*WriteFileHandle)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
return r, vfs, fh, cleanup
|
return r, vfs, fh
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteFileHandleMethods(t *testing.T) {
|
func TestWriteFileHandleMethods(t *testing.T) {
|
||||||
r, vfs, fh, cleanup := writeHandleCreate(t)
|
r, vfs, fh := writeHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// String
|
// String
|
||||||
assert.Equal(t, "file1 (w)", fh.String())
|
assert.Equal(t, "file1 (w)", fh.String())
|
||||||
|
@ -132,8 +131,7 @@ func TestWriteFileHandleMethods(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteFileHandleWriteAt(t *testing.T) {
|
func TestWriteFileHandleWriteAt(t *testing.T) {
|
||||||
r, vfs, fh, cleanup := writeHandleCreate(t)
|
r, vfs, fh := writeHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Preconditions
|
// Preconditions
|
||||||
assert.Equal(t, int64(0), fh.offset)
|
assert.Equal(t, int64(0), fh.offset)
|
||||||
|
@ -177,8 +175,7 @@ func TestWriteFileHandleWriteAt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteFileHandleFlush(t *testing.T) {
|
func TestWriteFileHandleFlush(t *testing.T) {
|
||||||
_, vfs, fh, cleanup := writeHandleCreate(t)
|
_, vfs, fh := writeHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Check Flush already creates file for unwritten handles, without closing it
|
// Check Flush already creates file for unwritten handles, without closing it
|
||||||
err := fh.Flush()
|
err := fh.Flush()
|
||||||
|
@ -210,8 +207,7 @@ func TestWriteFileHandleFlush(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteFileHandleRelease(t *testing.T) {
|
func TestWriteFileHandleRelease(t *testing.T) {
|
||||||
_, _, fh, cleanup := writeHandleCreate(t)
|
_, _, fh := writeHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
// Check Release closes file
|
// Check Release closes file
|
||||||
err := fh.Release()
|
err := fh.Release()
|
||||||
|
@ -258,8 +254,7 @@ func canSetModTime(t *testing.T, r *fstest.Run) bool {
|
||||||
|
|
||||||
// tests mod time on open files
|
// tests mod time on open files
|
||||||
func TestWriteFileModTimeWithOpenWriters(t *testing.T) {
|
func TestWriteFileModTimeWithOpenWriters(t *testing.T) {
|
||||||
r, vfs, fh, cleanup := writeHandleCreate(t)
|
r, vfs, fh := writeHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
if !canSetModTime(t, r) {
|
if !canSetModTime(t, r) {
|
||||||
t.Skip("can't set mod time")
|
t.Skip("can't set mod time")
|
||||||
|
@ -286,8 +281,7 @@ func TestWriteFileModTimeWithOpenWriters(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFileReadAt(t *testing.T, n int) {
|
func testFileReadAt(t *testing.T, n int) {
|
||||||
_, vfs, fh, cleanup := writeHandleCreate(t)
|
_, vfs, fh := writeHandleCreate(t)
|
||||||
defer cleanup()
|
|
||||||
|
|
||||||
contents := []byte(random.String(n))
|
contents := []byte(random.String(n))
|
||||||
if n != 0 {
|
if n != 0 {
|
||||||
|
|
Loading…
Reference in a new issue