2020-03-30 20:02:07 +00:00
|
|
|
package rados
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-07-24 00:19:57 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2020-03-30 20:02:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRadosError(t *testing.T) {
|
2020-03-30 20:57:54 +00:00
|
|
|
err := getError(0)
|
2020-03-30 20:02:07 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2020-03-30 20:57:54 +00:00
|
|
|
err = getError(-5) // IO error
|
2020-03-30 20:02:07 +00:00
|
|
|
assert.Error(t, err)
|
2020-08-10 15:04:32 +00:00
|
|
|
assert.Equal(t, err.Error(), "rados: ret=-5, Input/output error")
|
2020-03-30 20:02:07 +00:00
|
|
|
|
2020-08-10 14:31:40 +00:00
|
|
|
errno, ok := err.(interface{ ErrorCode() int })
|
2020-07-24 00:19:57 +00:00
|
|
|
assert.True(t, ok)
|
|
|
|
require.NotNil(t, errno)
|
2020-08-10 14:31:40 +00:00
|
|
|
assert.Equal(t, errno.ErrorCode(), -5)
|
2020-07-24 00:19:57 +00:00
|
|
|
|
2020-03-30 20:57:54 +00:00
|
|
|
err = getError(345) // no such errno
|
2020-03-30 20:02:07 +00:00
|
|
|
assert.Error(t, err)
|
|
|
|
assert.Equal(t, err.Error(), "rados: ret=345")
|
|
|
|
}
|