Skip to content

Commit

Permalink
tests: validate comparing with common cephError
Browse files Browse the repository at this point in the history
Signed-off-by: Niels de Vos <[email protected]>
Signed-off-by: Anoop C S <[email protected]>
  • Loading branch information
nixpanic authored and anoopcs9 committed Oct 14, 2024
1 parent 141078c commit b9b493f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions internal/errutil/error_test.go
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit b9b493f

Please sign in to comment.