2020-03-30 20:22:07 +00:00
|
|
|
package cephfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-07-24 00:19:57 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2020-03-30 20:22:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestCephFSError(t *testing.T) {
|
|
|
|
err := getError(0)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = getError(-5) // IO error
|
|
|
|
assert.Error(t, err)
|
|
|
|
assert.Equal(t, err.Error(), "cephfs: ret=5, Input/output error")
|
|
|
|
|
2020-07-24 00:19:57 +00:00
|
|
|
errno, ok := err.(interface{ Errno() int })
|
|
|
|
assert.True(t, ok)
|
|
|
|
require.NotNil(t, errno)
|
|
|
|
assert.Equal(t, errno.Errno(), -5)
|
|
|
|
|
2020-03-30 20:22:07 +00:00
|
|
|
err = getError(345) // no such errno
|
|
|
|
assert.Error(t, err)
|
|
|
|
assert.Equal(t, err.Error(), "cephfs: ret=345")
|
|
|
|
}
|