client statVFS: normalize the returned error

added a test case for the request server to check os.IsNotExist error
This commit is contained in:
Nicola Murino 2021-02-10 19:35:30 +01:00
parent 5dbfeffd12
commit 14bb577288
2 changed files with 18 additions and 1 deletions

View File

@ -638,7 +638,7 @@ func (c *Client) StatVFS(path string) (*StatVFS, error) {
// the resquest failed // the resquest failed
case sshFxpStatus: case sshFxpStatus:
return nil, errors.New(fxp(sshFxpStatus).String()) return nil, normaliseError(unmarshalStatus(id, data))
default: default:
return nil, unimplementedPacketErr(typ) return nil, unimplementedPacketErr(typ)

View File

@ -745,6 +745,23 @@ func TestRequestStatVFS(t *testing.T) {
require.Equal(t, expected.Bavail, vfs.Bavail) require.Equal(t, expected.Bavail, vfs.Bavail)
require.Equal(t, expected.Bfree, vfs.Bfree) require.Equal(t, expected.Bfree, vfs.Bfree)
require.Equal(t, expected.Blocks, vfs.Blocks) require.Equal(t, expected.Blocks, vfs.Blocks)
checkRequestServerAllocator(t, p)
}
func TestRequestStatVFSError(t *testing.T) {
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
t.Skip("StatVFS is implemented on linux and darwin")
}
p := clientRequestServerPair(t)
defer p.Close()
_, err := p.cli.StatVFS("a missing path")
require.Error(t, err)
require.True(t, os.IsNotExist(err))
checkRequestServerAllocator(t, p)
} }
func TestCleanDisconnect(t *testing.T) { func TestCleanDisconnect(t *testing.T) {