mirror of https://github.com/pkg/sftp.git
client statVFS: normalize the returned error
added a test case for the request server to check os.IsNotExist error
This commit is contained in:
parent
5dbfeffd12
commit
14bb577288
|
@ -638,7 +638,7 @@ func (c *Client) StatVFS(path string) (*StatVFS, error) {
|
|||
|
||||
// the resquest failed
|
||||
case sshFxpStatus:
|
||||
return nil, errors.New(fxp(sshFxpStatus).String())
|
||||
return nil, normaliseError(unmarshalStatus(id, data))
|
||||
|
||||
default:
|
||||
return nil, unimplementedPacketErr(typ)
|
||||
|
|
|
@ -745,6 +745,23 @@ func TestRequestStatVFS(t *testing.T) {
|
|||
require.Equal(t, expected.Bavail, vfs.Bavail)
|
||||
require.Equal(t, expected.Bfree, vfs.Bfree)
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue