Restore TestNonEmptyMountPoint for Linux.
I had forgotten that we explicitly handle the "mount point doesn't exist" case, so that wasn't tickling what I had hoped in fusermount.geesefs-0-30-9
parent
035636830f
commit
3da7af8c88
|
@ -4,6 +4,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -65,6 +66,51 @@ func TestSuccessfulMount(t *testing.T) {
|
||||||
defer fuse.Unmount(mfs.Dir())
|
defer fuse.Unmount(mfs.Dir())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNonEmptyMountPoint(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// osxfuse appears to be happy to mount over a non-empty mount point.
|
||||||
|
//
|
||||||
|
// We leave this test in for Linux, because it tickles the behavior of
|
||||||
|
// fusermount writing to stderr and exiting with an error code. We want to
|
||||||
|
// make sure that a descriptive error makes it back to the user.
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up a temporary directory.
|
||||||
|
dir, err := ioutil.TempDir("", "mount_test")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("ioutil.TempDir: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
|
// Add a file within it.
|
||||||
|
err = ioutil.WriteFile(path.Join(dir, "foo"), []byte{}, 0600)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ioutil.WriteFile: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to mount.
|
||||||
|
fs := &minimalFS{}
|
||||||
|
mfs, err := fuse.Mount(
|
||||||
|
dir,
|
||||||
|
fuseutil.NewFileSystemServer(fs),
|
||||||
|
&fuse.MountConfig{})
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
fuse.Unmount(mfs.Dir())
|
||||||
|
mfs.Join(ctx)
|
||||||
|
t.Fatal("fuse.Mount returned nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
const want = "not empty"
|
||||||
|
if got := err.Error(); !strings.Contains(got, want) {
|
||||||
|
t.Errorf("Unexpected error: %v", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestNonexistentMountPoint(t *testing.T) {
|
func TestNonexistentMountPoint(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue