[#302] pkg/xheader: Document default values set in NewXHeader
Document field values of instance constructed via `NewXHeader`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
41307a5e00
commit
1542162657
2 changed files with 20 additions and 0 deletions
|
@ -15,6 +15,10 @@ func NewXHeaderFromV2(v *session.XHeader) *XHeader {
|
|||
}
|
||||
|
||||
// NewXHeader creates, initializes and returns blank XHeader instance.
|
||||
//
|
||||
// Defaults:
|
||||
// - key: "";
|
||||
// - value: "".
|
||||
func NewXHeader() *XHeader {
|
||||
return NewXHeaderFromV2(new(session.XHeader))
|
||||
}
|
||||
|
|
|
@ -40,3 +40,19 @@ func TestXHeader_ToV2(t *testing.T) {
|
|||
require.Nil(t, x.ToV2())
|
||||
})
|
||||
}
|
||||
|
||||
func TestNewXHeader(t *testing.T) {
|
||||
t.Run("default values", func(t *testing.T) {
|
||||
xh := NewXHeader()
|
||||
|
||||
// check initial values
|
||||
require.Empty(t, xh.Value())
|
||||
require.Empty(t, xh.Key())
|
||||
|
||||
// convert to v2 message
|
||||
xhV2 := xh.ToV2()
|
||||
|
||||
require.Empty(t, xhV2.GetValue())
|
||||
require.Empty(t, xhV2.GetKey())
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue