forked from TrueCloudLab/frostfs-sdk-go
1d952ced4e
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
35 lines
680 B
Go
35 lines
680 B
Go
package apistatus_test
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestErrors(t *testing.T) {
|
|
t.Run("error source", func(t *testing.T) {
|
|
err := errors.New("some error")
|
|
|
|
st := apistatus.ErrToStatus(err)
|
|
|
|
success := apistatus.IsSuccessful(st)
|
|
require.False(t, success)
|
|
|
|
res := apistatus.ErrFromStatus(st)
|
|
|
|
require.ErrorIs(t, res, err)
|
|
})
|
|
|
|
t.Run("non-error source", func(t *testing.T) {
|
|
var st apistatus.Status = "any non-error type"
|
|
|
|
success := apistatus.IsSuccessful(st)
|
|
require.True(t, success)
|
|
|
|
res := apistatus.ErrFromStatus(st)
|
|
|
|
require.Nil(t, res)
|
|
})
|
|
}
|