diff --git a/pkg/xheader.go b/pkg/xheader.go index 84d645cf..78786772 100644 --- a/pkg/xheader.go +++ b/pkg/xheader.go @@ -8,6 +8,8 @@ import ( type XHeader session.XHeader // NewXHeaderFromV2 wraps v2 XHeader message to XHeader. +// +// Nil session.XHeader converts to nil. func NewXHeaderFromV2(v *session.XHeader) *XHeader { return (*XHeader)(v) } @@ -18,6 +20,8 @@ func NewXHeader() *XHeader { } // ToV2 converts XHeader to v2 XHeader message. +// +// Nil XHeader converts to nil. func (x *XHeader) ToV2() *session.XHeader { return (*session.XHeader)(x) } diff --git a/pkg/xheader_test.go b/pkg/xheader_test.go index 8f652278..66535bed 100644 --- a/pkg/xheader_test.go +++ b/pkg/xheader_test.go @@ -3,6 +3,7 @@ package pkg import ( "testing" + "github.com/nspcc-dev/neofs-api-go/v2/session" "github.com/stretchr/testify/require" ) @@ -23,3 +24,19 @@ func TestXHeader(t *testing.T) { require.Equal(t, key, xV2.GetKey()) require.Equal(t, val, xV2.GetValue()) } + +func TestNewXHeaderFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *session.XHeader + + require.Nil(t, NewXHeaderFromV2(x)) + }) +} + +func TestXHeader_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *XHeader + + require.Nil(t, x.ToV2()) + }) +}