diff --git a/pkg/object/id.go b/pkg/object/id.go index 21d566e9..e4871a93 100644 --- a/pkg/object/id.go +++ b/pkg/object/id.go @@ -16,6 +16,8 @@ type ID refs.ObjectID var errInvalidIDString = errors.New("incorrect format of the string object ID") // NewIDFromV2 wraps v2 ObjectID message to ID. +// +// Nil refs.ObjectID converts to nil. func NewIDFromV2(idV2 *refs.ObjectID) *ID { return (*ID)(idV2) } @@ -41,6 +43,8 @@ func (id *ID) Equal(id2 *ID) bool { } // ToV2 converts ID to v2 ObjectID message. +// +// Nil ID converts to nil. func (id *ID) ToV2() *refs.ObjectID { return (*refs.ObjectID)(id) } diff --git a/pkg/object/id_test.go b/pkg/object/id_test.go index a11e80b1..e5e80db2 100644 --- a/pkg/object/id_test.go +++ b/pkg/object/id_test.go @@ -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()) + }) +}