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 mergify[bot] committed Oct 14, 2024
1 parent b712180 commit 73d2b2c
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 73d2b2c

Please sign in to comment.