From bdee9f4aab6ef35eed4be1ee66be2423af2886c7 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 23 Mar 2020 17:11:21 -0400 Subject: [PATCH] cephfs: TestMountWithRoot should only try unmounting after mounting The defer function in TestMountWithRoot was always trying to call unmount before release. This is not correct if the fs was not mounted so we reorganize this code to more closely match what should be done in normal practice. Signed-off-by: John Mulligan --- cephfs/cephfs_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cephfs/cephfs_test.go b/cephfs/cephfs_test.go index 390f32d..1a223bc 100644 --- a/cephfs/cephfs_test.go +++ b/cephfs/cephfs_test.go @@ -354,7 +354,6 @@ func TestMountWithRoot(t *testing.T) { require.NoError(t, err) require.NotNil(t, mount) defer func() { - assert.NoError(t, mount.Unmount()) assert.NoError(t, mount.Release()) }() @@ -363,6 +362,9 @@ func TestMountWithRoot(t *testing.T) { err = mount.MountWithRoot(dir1) assert.NoError(t, err) + defer func() { + assert.NoError(t, mount.Unmount()) + }() err = mount.ChangeDir(sub1) assert.NoError(t, err)