diff --git a/pkg/reputation/trust.go b/pkg/reputation/trust.go index 5a25b691..c5847407 100644 --- a/pkg/reputation/trust.go +++ b/pkg/reputation/trust.go @@ -20,12 +20,16 @@ func NewTrust() *Trust { // TrustFromV2 converts NeoFS API v2 // reputation.Trust message structure to Trust. +// +// Nil reputation.Trust converts to nil. func TrustFromV2(t *reputation.Trust) *Trust { return (*Trust)(t) } // ToV2 converts Trust to NeoFS API v2 // reputation.Trust message structure. +// +// Nil Trust converts to nil. func (x *Trust) ToV2() *reputation.Trust { return (*reputation.Trust)(x) } @@ -111,12 +115,16 @@ func NewPeerToPeerTrust() *PeerToPeerTrust { // PeerToPeerTrustFromV2 converts NeoFS API v2 // reputation.PeerToPeerTrust message structure to PeerToPeerTrust. +// +// Nil reputation.PeerToPeerTrust converts to nil. func PeerToPeerTrustFromV2(t *reputation.PeerToPeerTrust) *PeerToPeerTrust { return (*PeerToPeerTrust)(t) } // ToV2 converts PeerToPeerTrust to NeoFS API v2 // reputation.PeerToPeerTrust message structure. +// +// Nil PeerToPeerTrust converts to nil. func (x *PeerToPeerTrust) ToV2() *reputation.PeerToPeerTrust { return (*reputation.PeerToPeerTrust)(x) } @@ -195,12 +203,16 @@ func NewGlobalTrust() *GlobalTrust { // GlobalTrustFromV2 converts NeoFS API v2 // reputation.GlobalTrust message structure to GlobalTrust. +// +// Nil reputation.GlobalTrust converts to nil. func GlobalTrustFromV2(t *reputation.GlobalTrust) *GlobalTrust { return (*GlobalTrust)(t) } // ToV2 converts GlobalTrust to NeoFS API v2 // reputation.GlobalTrust message structure. +// +// Nil GlobalTrust converts to nil. func (x *GlobalTrust) ToV2() *reputation.GlobalTrust { return (*reputation.GlobalTrust)(x) } diff --git a/pkg/reputation/trust_test.go b/pkg/reputation/trust_test.go index 0e908ec9..844997b0 100644 --- a/pkg/reputation/trust_test.go +++ b/pkg/reputation/trust_test.go @@ -6,6 +6,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/reputation" reputationtest "github.com/nspcc-dev/neofs-api-go/pkg/reputation/test" + reputationV2 "github.com/nspcc-dev/neofs-api-go/v2/reputation" reputationtestV2 "github.com/nspcc-dev/neofs-api-go/v2/reputation/test" "github.com/stretchr/testify/require" ) @@ -150,3 +151,51 @@ func TestGlobalTrust(t *testing.T) { }) }) } + +func TestTrustFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *reputationV2.Trust + + require.Nil(t, reputation.TrustFromV2(x)) + }) +} + +func TestPeerToPeerTrustFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *reputationV2.PeerToPeerTrust + + require.Nil(t, reputation.PeerToPeerTrustFromV2(x)) + }) +} + +func TestGlobalTrustFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *reputationV2.GlobalTrust + + require.Nil(t, reputation.GlobalTrustFromV2(x)) + }) +} + +func TestTrust_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *reputation.Trust + + require.Nil(t, x.ToV2()) + }) +} + +func TestPeerToPeerTrust_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *reputation.PeerToPeerTrust + + require.Nil(t, x.ToV2()) + }) +} + +func TestGlobalTrust_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *reputation.GlobalTrust + + require.Nil(t, x.ToV2()) + }) +}