diff --git a/pkg/xheader.go b/pkg/xheader.go index 78786772..b36f1f01 100644 --- a/pkg/xheader.go +++ b/pkg/xheader.go @@ -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)) } diff --git a/pkg/xheader_test.go b/pkg/xheader_test.go index 66535bed..22cbe87d 100644 --- a/pkg/xheader_test.go +++ b/pkg/xheader_test.go @@ -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()) + }) +}