From 8b7833ba01887382f298a1c9b287f2e96924eb4a Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 29 Feb 2016 13:40:11 +1100 Subject: [PATCH] TestNonEmptyMountPoint: clean up in the event of a successful mount. --- mount_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mount_test.go b/mount_test.go index 88b5388..f7234d5 100644 --- a/mount_test.go +++ b/mount_test.go @@ -66,6 +66,8 @@ func TestSuccessfulMount(t *testing.T) { } func TestNonEmptyMountPoint(t *testing.T) { + ctx := context.Background() + // Set up a temporary directory. dir, err := ioutil.TempDir("", "mount_test") if err != nil { @@ -82,13 +84,19 @@ func TestNonEmptyMountPoint(t *testing.T) { // Attempt to mount. fs := &minimalFS{} - _, err = fuse.Mount( + 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 err == nil || !strings.Contains(err.Error(), want) { - t.Errorf("Unexpected error: %v", err) + if got := err.Error(); !strings.Contains(got, want) { + t.Errorf("Unexpected error: %v", got) } }