Skip to content

Commit 461e687

Browse files
nixpanicanoopcs9
authored andcommitted
tests: validate comparing with common cephError
Signed-off-by: Niels de Vos <[email protected]> Signed-off-by: Anoop C S <[email protected]>
1 parent 564fc18 commit 461e687

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

internal/errutil/error_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package errutil
2+
3+
import (
4+
"errors"
5+
"fmt"
6+
"testing"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestCephError(t *testing.T) {
12+
radosErr := cephErrno(107)
13+
assert.Equal(t, "Transport endpoint is not connected", radosErr.Error())
14+
15+
cephFSErr := GetError("cephfs", 2)
16+
assert.Equal(t, "cephfs: ret=2, No such file or directory",
17+
cephFSErr.Error())
18+
assert.Equal(t, 2, cephFSErr.(cephError).ErrorCode())
19+
20+
rbdErr := fmt.Errorf("RBD image not found: %w", GetError("rbd", 2))
21+
assert.True(t, errors.Is(cephFSErr, errors.Unwrap(rbdErr)))
22+
}

0 commit comments

Comments
 (0)