[#168] session: Implement binary/JSON encoders/decoders on XHeader

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 16:58:08 +03:00 committed by Alex Vanin
parent 85d4713348
commit 7e3e9e1cba
4 changed files with 45 additions and 4 deletions

View file

@ -46,16 +46,14 @@ func TestCreateResponseBody_StableMarshal(t *testing.T) {
func TestXHeader_StableMarshal(t *testing.T) {
xheaderFrom := generateXHeader("X-Header-Key", "X-Header-Value")
transport := new(grpc.XHeader)
t.Run("non empty", func(t *testing.T) {
wire, err := xheaderFrom.StableMarshal(nil)
require.NoError(t, err)
err = goproto.Unmarshal(wire, transport)
require.NoError(t, err)
xheaderTo := new(session.XHeader)
require.NoError(t, xheaderTo.Unmarshal(wire))
xheaderTo := session.XHeaderFromGRPCMessage(transport)
require.Equal(t, xheaderFrom, xheaderTo)
})
}