frostfs-api-go/pkg/object/error_test.go
Alex Vanin 1fe0307711 [#223] pkg/object: Work with SplitInfoError via pointer
Closes #221

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-03 18:07:42 +03:00

33 lines
648 B
Go

package object_test
import (
"errors"
"testing"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/stretchr/testify/require"
)
func TestNewSplitInfoError(t *testing.T) {
var (
si = generateSplitInfo()
err error = object.NewSplitInfoError(si)
expectedErr *object.SplitInfoError
)
require.True(t, errors.As(err, &expectedErr))
siErr, ok := err.(*object.SplitInfoError)
require.True(t, ok)
require.Equal(t, si, siErr.SplitInfo())
}
func generateSplitInfo() *object.SplitInfo {
si := object.NewSplitInfo()
si.SetSplitID(object.NewSplitID())
si.SetLastPart(generateID())
si.SetLink(generateID())
return si
}