From 73d2b2c14d69aca77bf9f2f4c554efac2caae471 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 2 Oct 2024 16:46:54 +0200 Subject: [PATCH] tests: validate comparing with common cephError Signed-off-by: Niels de Vos Signed-off-by: Anoop C S --- internal/errutil/error_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 internal/errutil/error_test.go diff --git a/internal/errutil/error_test.go b/internal/errutil/error_test.go new file mode 100644 index 0000000..5c1784e --- /dev/null +++ b/internal/errutil/error_test.go @@ -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)) +}