mirror of
https://github.com/ceph/go-ceph
synced 2024-12-13 09:57:26 +00:00
849fc3c1f3
Signed-off-by: John Mulligan <jmulligan@redhat.com>
27 lines
590 B
Go
27 lines
590 B
Go
package rbd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRBDError(t *testing.T) {
|
|
err := getError(0)
|
|
assert.NoError(t, err)
|
|
|
|
err = getError(-39) // NOTEMPTY (image still has a snapshot)
|
|
assert.Error(t, err)
|
|
assert.Equal(t, err.Error(), "rbd: ret=-39, Directory not empty")
|
|
|
|
errno, ok := err.(interface{ ErrorCode() int })
|
|
assert.True(t, ok)
|
|
require.NotNil(t, errno)
|
|
assert.Equal(t, errno.ErrorCode(), -39)
|
|
|
|
err = getError(345) // no such errno
|
|
assert.Error(t, err)
|
|
assert.Equal(t, err.Error(), "rbd: ret=345")
|
|
}
|