mirror of
https://github.com/ceph/go-ceph
synced 2024-12-17 20:05:36 +00:00
tests: validate comparing with common cephError
Signed-off-by: Niels de Vos <ndevos@ibm.com> Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
This commit is contained in:
parent
b712180b45
commit
73d2b2c14d
22
internal/errutil/error_test.go
Normal file
22
internal/errutil/error_test.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package errutil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCephError(t *testing.T) {
|
||||||
|
radosErr := cephErrno(107)
|
||||||
|
assert.Equal(t, "Transport endpoint is not connected", radosErr.Error())
|
||||||
|
|
||||||
|
cephFSErr := GetError("cephfs", 2)
|
||||||
|
assert.Equal(t, "cephfs: ret=2, No such file or directory",
|
||||||
|
cephFSErr.Error())
|
||||||
|
assert.Equal(t, 2, cephFSErr.(cephError).ErrorCode())
|
||||||
|
|
||||||
|
rbdErr := GetError("rbd", 2)
|
||||||
|
assert.True(t, errors.Is(cephFSErr, rbdErr))
|
||||||
|
assert.True(t, errors.Unwrap(cephFSErr) == errors.Unwrap(rbdErr))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user