Home / File/ render_msgpack_test.go — gin Source File

render_msgpack_test.go — gin Source File

Architecture documentation for render_msgpack_test.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go ResponseRendering TemplateEngine 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  39a9dbe4_6067_eb34_d073_947fc26b5246["render_msgpack_test.go"]
  fefe783b_8987_7aed_66c9_b2860bfc32e7["bytes"]
  39a9dbe4_6067_eb34_d073_947fc26b5246 --> fefe783b_8987_7aed_66c9_b2860bfc32e7
  style 39a9dbe4_6067_eb34_d073_947fc26b5246 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

//go:build !nomsgpack

package render

import (
	"bytes"
	"net/http/httptest"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/ugorji/go/codec"
)

// TODO unit tests
// test errors

func TestRenderMsgPack(t *testing.T) {
	w := httptest.NewRecorder()
	data := map[string]any{
		"foo": "bar",
	}

	(MsgPack{data}).WriteContentType(w)
	assert.Equal(t, "application/msgpack; charset=utf-8", w.Header().Get("Content-Type"))

	err := (MsgPack{data}).Render(w)

	require.NoError(t, err)

	h := new(codec.MsgpackHandle)
	assert.NotNil(t, h)
	buf := bytes.NewBuffer([]byte{})
	assert.NotNil(t, buf)
	err = codec.NewEncoder(buf, h).Encode(data)

	require.NoError(t, err)
	assert.Equal(t, w.Body.String(), buf.String())
	assert.Equal(t, "application/msgpack; charset=utf-8", w.Header().Get("Content-Type"))
}

Subdomains

Dependencies

  • bytes

Frequently Asked Questions

What does render_msgpack_test.go do?
render_msgpack_test.go is a source file in the gin codebase, written in go. It belongs to the ResponseRendering domain, TemplateEngine subdomain.
What functions are defined in render_msgpack_test.go?
render_msgpack_test.go defines 1 function(s): TestRenderMsgPack.
What does render_msgpack_test.go depend on?
render_msgpack_test.go imports 1 module(s): bytes.
Where is render_msgpack_test.go in the architecture?
render_msgpack_test.go is located at render/render_msgpack_test.go (domain: ResponseRendering, subdomain: TemplateEngine, directory: render).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free