mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
ssh commands: return better error messages
This improve the fix for #171 and return better error message for SSH commands other than SCP too
This commit is contained in:
@@ -227,7 +227,7 @@ func TestRemoveDir(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
err = c.RemoveDir(testDir, "testDir")
|
||||
if assert.Error(t, err) {
|
||||
assert.EqualError(t, err, c.GetGenericError().Error())
|
||||
assert.EqualError(t, err, c.GetGenericError(err).Error())
|
||||
}
|
||||
err = os.Remove(testDir)
|
||||
assert.NoError(t, err)
|
||||
@@ -349,7 +349,7 @@ func TestRename(t *testing.T) {
|
||||
// and so the remaining space cannot be computed
|
||||
err = c.Rename(filepath.Join(user.GetHomeDir(), "adir"), filepath.Join(user.GetHomeDir(), "another"), "/vdir1/sub/a", "/vdir2/b")
|
||||
if assert.Error(t, err) {
|
||||
assert.EqualError(t, err, c.GetGenericError().Error())
|
||||
assert.EqualError(t, err, c.GetGenericError(err).Error())
|
||||
}
|
||||
|
||||
err = os.RemoveAll(mappedPath1)
|
||||
@@ -409,7 +409,7 @@ func TestCreateSymlink(t *testing.T) {
|
||||
}
|
||||
err = c.CreateSymlink(filepath.Join(user.GetHomeDir(), "b"), mappedPath1, "/vdir1/b", "/vdir2/b")
|
||||
if assert.Error(t, err) {
|
||||
assert.EqualError(t, err, c.GetGenericError().Error())
|
||||
assert.EqualError(t, err, c.GetOpUnsupportedError().Error())
|
||||
}
|
||||
err = c.CreateSymlink(mappedPath1, filepath.Join(mappedPath1, "b"), "/vdir1/a", "/vdir1/b")
|
||||
if assert.Error(t, err) {
|
||||
@@ -1140,6 +1140,12 @@ func TestErrorsMapping(t *testing.T) {
|
||||
} else {
|
||||
assert.EqualError(t, err, ErrGenericFailure.Error())
|
||||
}
|
||||
err = conn.GetFsError(ErrPermissionDenied)
|
||||
if protocol == ProtocolSFTP {
|
||||
assert.EqualError(t, err, sftp.ErrSSHFxFailure.Error())
|
||||
} else {
|
||||
assert.EqualError(t, err, ErrPermissionDenied.Error())
|
||||
}
|
||||
err = conn.GetFsError(nil)
|
||||
assert.NoError(t, err)
|
||||
err = conn.GetOpUnsupportedError()
|
||||
|
||||
Reference in New Issue
Block a user