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:
Niels de Vos 2024-10-02 16:46:54 +02:00 committed by mergify[bot]
parent b712180b45
commit 73d2b2c14d

View 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))
}