add TestRenderProtoBuf

This commit is contained in:
salamer 2018-08-12 15:32:35 +08:00
parent 5682f53f38
commit 42dd325de4
2 changed files with 11 additions and 1 deletions

View File

@ -17,11 +17,12 @@ import (
"testing" "testing"
"time" "time"
"io"
"github.com/gin-contrib/sse" "github.com/gin-contrib/sse"
"github.com/gin-gonic/gin/binding" "github.com/gin-gonic/gin/binding"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"golang.org/x/net/context" "golang.org/x/net/context"
"io"
) )
var _ context.Context = &Context{} var _ context.Context = &Context{}
@ -953,6 +954,12 @@ func TestContextRenderYAML(t *testing.T) {
assert.Equal(t, "application/x-yaml; charset=utf-8", w.HeaderMap.Get("Content-Type")) assert.Equal(t, "application/x-yaml; charset=utf-8", w.HeaderMap.Get("Content-Type"))
} }
// TestContextRenderProtoBuf tests that the response is serialized as ProtoBuf
// and Content-Type is set to application/x-protobuf
// and we just use the example protobuf to check if the response is correct
func TestContextRenderProtoBuf(t *testing.T) {
}
func TestContextHeaders(t *testing.T) { func TestContextHeaders(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder()) c, _ := CreateTestContext(httptest.NewRecorder())
c.Header("Content-Type", "text/plain") c.Header("Content-Type", "text/plain")

View File

@ -237,6 +237,9 @@ b:
assert.Equal(t, "application/x-yaml; charset=utf-8", w.Header().Get("Content-Type")) assert.Equal(t, "application/x-yaml; charset=utf-8", w.Header().Get("Content-Type"))
} }
func TestRenderProtoBuf(t *testing.T) {
}
type fail struct{} type fail struct{}
// Hook MarshalYAML // Hook MarshalYAML