forked from TrueCloudLab/frostfs-sdk-go
[#83] client: Implement status library
Define base `Status` interface. Provide the functionality to distinguish success and failure returns. Provide functionality to transport statuses over NeoFS API V2 protocol. Support success `OK` and failure `INTERNAL` returns. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
fc18ca2cb3
commit
9dcff95a29
20 changed files with 475 additions and 210 deletions
35
client/status/status_test.go
Normal file
35
client/status/status_test.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
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.Equal(t, err, res)
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue