cephfs: add a test case for calling Statx on an invalid mount

Adding this test case gets test coverage to 100% for path.go.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-11-11 16:25:31 -05:00 committed by mergify[bot]
parent 7cbacf9331
commit 36abb07dc5
1 changed files with 21 additions and 13 deletions

View File

@ -359,23 +359,31 @@ func TestReadlink(t *testing.T) {
}
func TestStatx(t *testing.T) {
mount := fsConnect(t)
defer fsDisconnect(t, mount)
t.Run("statPath", func(t *testing.T) {
mount := fsConnect(t)
defer fsDisconnect(t, mount)
dirname := "statme"
assert.NoError(t, mount.MakeDir(dirname, 0755))
dirname := "statme"
assert.NoError(t, mount.MakeDir(dirname, 0755))
st, err := mount.Statx(dirname, StatxBasicStats, 0)
assert.NoError(t, err)
assert.NotNil(t, st)
assert.Equal(t, uint16(0755), st.Mode&0777)
st, err := mount.Statx(dirname, StatxBasicStats, 0)
assert.NoError(t, err)
assert.NotNil(t, st)
assert.Equal(t, uint16(0755), st.Mode&0777)
assert.NoError(t, mount.RemoveDir(dirname))
assert.NoError(t, mount.RemoveDir(dirname))
st, err = mount.Statx(dirname, StatxBasicStats, 0)
assert.Error(t, err)
assert.Nil(t, st)
assert.Equal(t, errNoEntry, err)
st, err = mount.Statx(dirname, StatxBasicStats, 0)
assert.Error(t, err)
assert.Nil(t, st)
assert.Equal(t, errNoEntry, err)
})
t.Run("invalidMount", func(t *testing.T) {
m := &MountInfo{}
_, err := m.Statx("junk", StatxBasicStats, 0)
assert.Error(t, err)
})
}
func TestRename(t *testing.T) {