[#302] pkg/object: Convert nil SplitInfo to nil message

Document that `SplitInfo.ToV2` method return `nil`
when called on `nil`. Document that `NewSplitInfoFromV2`
function return `nil` when called on `nil`. Write
corresponding unit tests.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-08 19:27:53 +03:00 committed by Alex Vanin
parent d443904e43
commit 5cbdef1e46
2 changed files with 23 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import (
"testing"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
objv2 "github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/stretchr/testify/require"
)
@ -51,3 +52,19 @@ func generateID() *object.ID {
return id
}
func TestNewSplitInfoFromV2(t *testing.T) {
t.Run("from nil", func(t *testing.T) {
var x *objv2.SplitInfo
require.Nil(t, object.NewSplitInfoFromV2(x))
})
}
func TestSplitInfo_ToV2(t *testing.T) {
t.Run("nil", func(t *testing.T) {
var x *object.SplitInfo
require.Nil(t, x.ToV2())
})
}