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 <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-03-23 17:11:21 -04:00 committed by John Mulligan
parent 6a08124775
commit bdee9f4aab
1 changed files with 3 additions and 1 deletions

View File

@ -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)