mirror of
https://github.com/rclone/rclone.git
synced 2026-01-04 01:23:24 +00:00
mount/cmount: factor duplicated code into mountlib
This commit is contained in:
@@ -46,12 +46,10 @@ var (
|
||||
)
|
||||
|
||||
// TestMain drives the tests
|
||||
func TestMain(m *testing.M, fn MountFn, dirPerms, filePerms os.FileMode) {
|
||||
func TestMain(m *testing.M, fn MountFn) {
|
||||
mountFn = fn
|
||||
flag.Parse()
|
||||
run = newRun()
|
||||
run.dirPerms = dirPerms
|
||||
run.filePerms = filePerms
|
||||
rc := m.Run()
|
||||
run.Finalise()
|
||||
os.Exit(rc)
|
||||
@@ -59,15 +57,14 @@ func TestMain(m *testing.M, fn MountFn, dirPerms, filePerms os.FileMode) {
|
||||
|
||||
// Run holds the remotes for a test run
|
||||
type Run struct {
|
||||
filesys *mountlib.FS
|
||||
mountPath string
|
||||
fremote fs.Fs
|
||||
fremoteName string
|
||||
cleanRemote func()
|
||||
umountResult <-chan error
|
||||
umountFn UnmountFn
|
||||
skip bool
|
||||
dirPerms, filePerms os.FileMode
|
||||
filesys *mountlib.FS
|
||||
mountPath string
|
||||
fremote fs.Fs
|
||||
fremoteName string
|
||||
cleanRemote func()
|
||||
umountResult <-chan error
|
||||
umountFn UnmountFn
|
||||
skip bool
|
||||
}
|
||||
|
||||
// run holds the master Run data
|
||||
@@ -230,10 +227,10 @@ func (r *Run) readLocal(t *testing.T, dir dirMap, filepath string) {
|
||||
if fi.IsDir() {
|
||||
dir[name+"/"] = struct{}{}
|
||||
r.readLocal(t, dir, name)
|
||||
assert.Equal(t, r.dirPerms, fi.Mode().Perm())
|
||||
assert.Equal(t, mountlib.DirPerms, fi.Mode().Perm())
|
||||
} else {
|
||||
dir[fmt.Sprintf("%s %d", name, fi.Size())] = struct{}{}
|
||||
assert.Equal(t, r.filePerms, fi.Mode().Perm())
|
||||
assert.Equal(t, mountlib.FilePerms, fi.Mode().Perm())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,5 +312,5 @@ func TestRoot(t *testing.T) {
|
||||
fi, err := os.Lstat(run.mountPath)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, fi.IsDir())
|
||||
assert.Equal(t, fi.Mode().Perm(), run.dirPerms)
|
||||
assert.Equal(t, fi.Mode().Perm(), mountlib.DirPerms)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user