[#302] pkg/audit: Convert nil Result to nil message

Document that `Result.ToV2` method returns
`nil` when is called on `nil`. Document that
`NewResultFromV2` method returns `nil` when
is called on `nil`. Add
corresponding unit test.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-08 14:33:56 +03:00 committed by Alex Vanin
parent 4e2ef6a30a
commit 821e2951b6
2 changed files with 21 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import (
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
objecttest "github.com/nspcc-dev/neofs-api-go/pkg/object/test"
auditv2 "github.com/nspcc-dev/neofs-api-go/v2/audit"
"github.com/stretchr/testify/require"
)
@ -91,3 +92,19 @@ func TestStorageGroupEncoding(t *testing.T) {
require.Equal(t, r, r2)
})
}
func TestResult_ToV2(t *testing.T) {
t.Run("nil", func(t *testing.T) {
var x *audit.Result
require.Nil(t, x.ToV2())
})
}
func TestNewResultFromV2(t *testing.T) {
t.Run("from nil", func(t *testing.T) {
var x *auditv2.DataAuditResult
require.Nil(t, audit.NewResultFromV2(x))
})
}