From 4c1447bc296d9822cea2a9cba0fc080e71703427 Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Tue, 26 May 2015 12:11:59 +0200 Subject: [PATCH] Fixes unit tests --- context_test.go | 40 ++++++++++++++++++++-------------------- routes_test.go | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/context_test.go b/context_test.go index 49aad52..f7279d4 100644 --- a/context_test.go +++ b/context_test.go @@ -118,17 +118,17 @@ func TestContextFormParse(t *testing.T) { c, _, _ := createTestContext() c.Request, _ = http.NewRequest("GET", "http://example.com/?foo=bar&page=10", nil) - assert.Equal(t, c.DefaultFormValue("foo", "none"), "bar") - assert.Equal(t, c.FormValue("foo"), "bar") - assert.Empty(t, c.PostFormValue("foo")) + assert.Equal(t, c.DefaultQuery("foo", "none"), "bar") + assert.Equal(t, c.Query("foo"), "bar") + assert.Empty(t, c.PostForm("foo")) - assert.Equal(t, c.DefaultFormValue("page", "0"), "10") - assert.Equal(t, c.FormValue("page"), "10") - assert.Empty(t, c.PostFormValue("page")) + assert.Equal(t, c.DefaultQuery("page", "0"), "10") + assert.Equal(t, c.Query("page"), "10") + assert.Empty(t, c.PostForm("page")) - assert.Equal(t, c.DefaultFormValue("NoKey", "nada"), "nada") - assert.Empty(t, c.FormValue("NoKey")) - assert.Empty(t, c.PostFormValue("NoKey")) + assert.Equal(t, c.DefaultQuery("NoKey", "nada"), "nada") + assert.Empty(t, c.Query("NoKey")) + assert.Empty(t, c.PostForm("NoKey")) } func TestContextPostFormParse(t *testing.T) { @@ -137,23 +137,23 @@ func TestContextPostFormParse(t *testing.T) { c.Request, _ = http.NewRequest("POST", "/?both=GET&id=main", body) c.Request.Header.Add("Content-Type", MIMEPOSTForm) - assert.Equal(t, c.DefaultPostFormValue("foo", "none"), "bar") - assert.Equal(t, c.PostFormValue("foo"), "bar") - assert.Empty(t, c.FormValue("foo")) + assert.Equal(t, c.DefaultPostForm("foo", "none"), "bar") + assert.Equal(t, c.PostForm("foo"), "bar") + assert.Empty(t, c.Query("foo")) assert.Equal(t, c.DefaultPostForm("page", "0"), "11") assert.Equal(t, c.PostForm("page"), "11") - assert.Equal(t, c.InputQuery("page"), "") + assert.Equal(t, c.Query("page"), "") - assert.Equal(t, c.PostFormValue("both"), "POST") - assert.Equal(t, c.FormValue("both"), "GET") + assert.Equal(t, c.PostForm("both"), "POST") + assert.Equal(t, c.Query("both"), "GET") - assert.Equal(t, c.FormValue("id"), "main") - assert.Empty(t, c.PostFormValue("id")) + assert.Equal(t, c.Query("id"), "main") + assert.Empty(t, c.PostForm("id")) - assert.Equal(t, c.DefaultPostFormValue("NoKey", "nada"), "nada") - assert.Empty(t, c.PostFormValue("NoKey")) - assert.Empty(t, c.FormValue("NoKey")) + assert.Equal(t, c.DefaultPostForm("NoKey", "nada"), "nada") + assert.Empty(t, c.PostForm("NoKey")) + assert.Empty(t, c.Query("NoKey")) c.Param("page") c.Query("page") diff --git a/routes_test.go b/routes_test.go index 4bd0682..04032c2 100644 --- a/routes_test.go +++ b/routes_test.go @@ -126,8 +126,8 @@ func TestRouteParamsByName(t *testing.T) { lastName = c.Params.ByName("last_name") wild = c.Params.ByName("wild") - assert.Equal(t, name, c.ParamValue("name")) - assert.Equal(t, lastName, c.ParamValue("last_name")) + assert.Equal(t, name, c.Param("name")) + assert.Equal(t, lastName, c.Param("last_name")) }) w := performRequest(router, "GET", "/test/john/smith/is/super/great")