Skip to content
Myr

render_msgpack_test.go

This file

Path

render/render_msgpack_test.go

43 lines · 977 bytes · Go

Last changed by

chore: support min go version 1.18 (#3511)thinkeroubefore adoption1e1f0b1

History of this file

Take it

The walk stopped after 200 commits: lines older than a550c56 point at it.

add v1.8.0 changelog (#3160)thinkeroubefore adoption38eb5ac

line 1why, one step back
1// Copyright 2014 Manu Martinez-Almeida. All rights reserved.

chore: Add go1.17 for testing (#2828)Bo-Yi Wubefore adoptiona550c56

lines 2–22why, one step back
2// Use of this source code is governed by a MIT style
3// license that can be found in the LICENSE file.45//go:build !nomsgpack67package render89import (10 "bytes"11 "net/http/httptest"12 "testing"1314 "github.com/stretchr/testify/assert"15 "github.com/ugorji/go/codec"16)1718// TODO unit tests19// test errors2021func TestRenderMsgPack(t *testing.T) {22 w := httptest.NewRecorder()

test support go1.18 (#2990)thinkeroubefore adoption2bde107

line 23why, one step back
23 data := map[string]any{

chore: Add go1.17 for testing (#2828)Bo-Yi Wubefore adoptiona550c56

lines 24–43why, one step back
24 "foo": "bar",
25 }2627 (MsgPack{data}).WriteContentType(w)28 assert.Equal(t, "application/msgpack; charset=utf-8", w.Header().Get("Content-Type"))2930 err := (MsgPack{data}).Render(w)3132 assert.NoError(t, err)3334 h := new(codec.MsgpackHandle)35 assert.NotNil(t, h)36 buf := bytes.NewBuffer([]byte{})37 assert.NotNil(t, buf)38 err = codec.NewEncoder(buf, h).Encode(data)3940 assert.NoError(t, err)41 assert.Equal(t, w.Body.String(), buf.String())42 assert.Equal(t, "application/msgpack; charset=utf-8", w.Header().Get("Content-Type"))43}