[#302] pkg/signature: Document default values set in NewSignature
Document field values of instance constructed via `NewSignature`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
b506970636
commit
bb0cd8e4c0
2 changed files with 21 additions and 1 deletions
|
@ -17,6 +17,10 @@ func NewSignatureFromV2(sV2 *refs.Signature) *Signature {
|
||||||
// NewSignature creates and initializes blank Signature.
|
// NewSignature creates and initializes blank Signature.
|
||||||
//
|
//
|
||||||
// Works similar as NewSignatureFromV2(new(Signature)).
|
// Works similar as NewSignatureFromV2(new(Signature)).
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - key: nil;
|
||||||
|
// - signature: nil.
|
||||||
func NewSignature() *Signature {
|
func NewSignature() *Signature {
|
||||||
return NewSignatureFromV2(new(refs.Signature))
|
return NewSignatureFromV2(new(refs.Signature))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,3 +48,19 @@ func TestSignature_ToV2(t *testing.T) {
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewSignature(t *testing.T) {
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
sg := NewSignature()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Nil(t, sg.Key())
|
||||||
|
require.Nil(t, sg.Sign())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
sgV2 := sg.ToV2()
|
||||||
|
|
||||||
|
require.Nil(t, sgV2.GetKey())
|
||||||
|
require.Nil(t, sgV2.GetSign())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue