Skip to content
Myr

deprecated_test.go

This file

Path

deprecated_test.go

33 lines · 780 bytes · Go

Last changed by

Not known.

History of this file

Take it

1// Copyright 2014 Manu Martinez-Almeida. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package gin67import (8	"bytes"9	"net/http"10	"net/http/httptest"11	"testing"1213	"github.com/gin-gonic/gin/binding"14	"github.com/stretchr/testify/assert"15)1617func TestBindWith(t *testing.T) {18	w := httptest.NewRecorder()19	c, _ := CreateTestContext(w)2021	c.Request, _ = http.NewRequest(http.MethodPost, "/?foo=bar&bar=foo", bytes.NewBufferString("foo=unused"))2223	var obj struct {24		Foo string `form:"foo"`25		Bar string `form:"bar"`26	}27	captureOutput(t, func() {28		assert.NoError(t, c.BindWith(&obj, binding.Form))29	})30	assert.Equal(t, "foo", obj.Bar)31	assert.Equal(t, "bar", obj.Foo)32	assert.Equal(t, 0, w.Body.Len())33}