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 564fc18 commit b811908
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/errutil/error_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package errutil

import (
"errors"
"fmt"
"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 := fmt.Errorf("RBD image not found: %w",
GetError("rbd", 2))
assert.True(t, errors.Is(cephFSErr, errors.Unwrap(rbdErr)))
}

0 comments on commit b811908

Please sign in to comment.