test: use MustNewRequest.

This commit is contained in:
Fernandez Ludovic 2017-06-03 14:58:35 +02:00 committed by Ludovic Fernandez
parent 2223587fc0
commit a1a0420314
7 changed files with 27 additions and 37 deletions

View file

@ -6,6 +6,7 @@ import (
"testing"
"github.com/containous/mux"
"github.com/containous/traefik/testhelpers"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -20,7 +21,7 @@ func TestParseOneRule(t *testing.T) {
routeResult, err := rules.Parse(expression)
require.NoError(t, err, "Error while building route for %s", expression)
request, err := http.NewRequest("GET", "http://foo.bar", nil)
request := testhelpers.MustNewRequest(http.MethodGet, "http://foo.bar", nil)
routeMatch := routeResult.Match(request, &mux.RouteMatch{Route: routeResult})
assert.True(t, routeMatch, "Rule %s don't match.", expression)
@ -37,12 +38,12 @@ func TestParseTwoRules(t *testing.T) {
require.NoError(t, err, "Error while building route for %s.", expression)
request, _ := http.NewRequest("GET", "http://foo.bar/foobar", nil)
request := testhelpers.MustNewRequest(http.MethodGet, "http://foo.bar/foobar", nil)
routeMatch := routeResult.Match(request, &mux.RouteMatch{Route: routeResult})
assert.False(t, routeMatch, "Rule %s don't match.", expression)
request, _ = http.NewRequest("GET", "http://foo.bar/FOObar", nil)
request = testhelpers.MustNewRequest(http.MethodGet, "http://foo.bar/FOObar", nil)
routeMatch = routeResult.Match(request, &mux.RouteMatch{Route: routeResult})
assert.True(t, routeMatch, "Rule %s don't match.", expression)