TestNonEmptyMountPoint: clean up in the event of a successful mount.

geesefs-0-30-9
Aaron Jacobs 2016-02-29 13:40:11 +11:00
parent 38175a2e8b
commit 8b7833ba01
1 changed files with 11 additions and 3 deletions

View File

@ -66,6 +66,8 @@ func TestSuccessfulMount(t *testing.T) {
} }
func TestNonEmptyMountPoint(t *testing.T) { func TestNonEmptyMountPoint(t *testing.T) {
ctx := context.Background()
// Set up a temporary directory. // Set up a temporary directory.
dir, err := ioutil.TempDir("", "mount_test") dir, err := ioutil.TempDir("", "mount_test")
if err != nil { if err != nil {
@ -82,13 +84,19 @@ func TestNonEmptyMountPoint(t *testing.T) {
// Attempt to mount. // Attempt to mount.
fs := &minimalFS{} fs := &minimalFS{}
_, err = fuse.Mount( mfs, err := fuse.Mount(
dir, dir,
fuseutil.NewFileSystemServer(fs), fuseutil.NewFileSystemServer(fs),
&fuse.MountConfig{}) &fuse.MountConfig{})
if err == nil {
fuse.Unmount(mfs.Dir())
mfs.Join(ctx)
t.Fatal("fuse.Mount returned nil")
}
const want = "not empty" const want = "not empty"
if err == nil || !strings.Contains(err.Error(), want) { if got := err.Error(); !strings.Contains(got, want) {
t.Errorf("Unexpected error: %v", err) t.Errorf("Unexpected error: %v", got)
} }
} }