mirror of
https://github.com/ceph/go-ceph
synced 2024-12-23 14:45:42 +00:00
828ea92a51
This change removes StrError, as it was unused. Instead we add FormatErrorCode which should replace the common code that was previously repeated for all error-code types, along with consistently printing the raw error code value's sign (minus sign when negative). Signed-off-by: John Mulligan <jmulligan@redhat.com>
33 lines
698 B
Go
33 lines
698 B
Go
package errutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFormatError(t *testing.T) {
|
|
e, msg := FormatErrno(39)
|
|
assert.Equal(t, 39, e)
|
|
assert.Equal(t, msg, "Directory not empty")
|
|
|
|
e, msg = FormatErrno(-5)
|
|
assert.Equal(t, 5, e)
|
|
assert.Equal(t, msg, "Input/output error")
|
|
|
|
e, msg = FormatErrno(345)
|
|
assert.Equal(t, 345, e)
|
|
assert.Equal(t, msg, "")
|
|
}
|
|
|
|
func TestFormatErrorCode(t *testing.T) {
|
|
msg := FormatErrorCode("test", -39)
|
|
assert.Equal(t, msg, "test: ret=-39, Directory not empty")
|
|
|
|
msg = FormatErrorCode("test", -5)
|
|
assert.Equal(t, msg, "test: ret=-5, Input/output error")
|
|
|
|
msg = FormatErrorCode("boop", 345)
|
|
assert.Equal(t, msg, "boop: ret=345")
|
|
}
|