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

Document that `ID.ToV2` method return `nil`
when called on `nil`. Document that `NewIDFromV2`
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 18:58:12 +03:00 committed by Alex Vanin
parent ff851215b0
commit 245a55f715
2 changed files with 21 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import (
"testing"
"github.com/mr-tron/base58"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/stretchr/testify/require"
)
@ -107,3 +108,19 @@ func TestObjectIDEncoding(t *testing.T) {
require.Equal(t, id, a2)
})
}
func TestNewIDFromV2(t *testing.T) {
t.Run("from nil", func(t *testing.T) {
var x *refs.ObjectID
require.Nil(t, NewIDFromV2(x))
})
}
func TestID_ToV2(t *testing.T) {
t.Run("nil", func(t *testing.T) {
var x *ID
require.Nil(t, x.ToV2())
})
}