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 461e687
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"
"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 461e687

Please sign in to comment.