|
|
|
|
@ -36,6 +36,7 @@ type routeTest struct {
@@ -36,6 +36,7 @@ type routeTest struct {
|
|
|
|
|
scheme string // the expected scheme of the built URL
|
|
|
|
|
host string // the expected host of the built URL
|
|
|
|
|
path string // the expected path of the built URL
|
|
|
|
|
query string // the expected query string to match
|
|
|
|
|
pathTemplate string // the expected path template of the route
|
|
|
|
|
hostTemplate string // the expected host template of the route
|
|
|
|
|
methods []string // the expected route methods
|
|
|
|
|
@ -744,6 +745,7 @@ func TestQueries(t *testing.T) {
@@ -744,6 +745,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=bar&baz=ding", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -753,6 +755,7 @@ func TestQueries(t *testing.T) {
@@ -753,6 +755,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=bar&baz=ding", |
|
|
|
|
pathTemplate: `/api`, |
|
|
|
|
hostTemplate: `www.example.com`, |
|
|
|
|
shouldMatch: true, |
|
|
|
|
@ -764,6 +767,7 @@ func TestQueries(t *testing.T) {
@@ -764,6 +767,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=bar&baz=ding", |
|
|
|
|
pathTemplate: `/api`, |
|
|
|
|
hostTemplate: `www.example.com`, |
|
|
|
|
shouldMatch: true, |
|
|
|
|
@ -784,6 +788,7 @@ func TestQueries(t *testing.T) {
@@ -784,6 +788,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v1": "bar"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=bar", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -793,6 +798,7 @@ func TestQueries(t *testing.T) {
@@ -793,6 +798,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v1": "bar", "v2": "ding"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=bar&baz=ding", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -802,6 +808,7 @@ func TestQueries(t *testing.T) {
@@ -802,6 +808,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v1": "10"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=10", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -820,6 +827,7 @@ func TestQueries(t *testing.T) {
@@ -820,6 +827,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v1": "1"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=1", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -829,6 +837,7 @@ func TestQueries(t *testing.T) {
@@ -829,6 +837,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v1": "1"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=1", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -847,6 +856,7 @@ func TestQueries(t *testing.T) {
@@ -847,6 +856,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v1": "1a"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=1a", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -865,6 +875,7 @@ func TestQueries(t *testing.T) {
@@ -865,6 +875,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v-1": "bar"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=bar", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -874,6 +885,7 @@ func TestQueries(t *testing.T) {
@@ -874,6 +885,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v-1": "bar", "v-2": "ding"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=bar&baz=ding", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -883,6 +895,7 @@ func TestQueries(t *testing.T) {
@@ -883,6 +895,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v-1": "10"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=10", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -892,6 +905,7 @@ func TestQueries(t *testing.T) {
@@ -892,6 +905,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"v-1": "1a"}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=1a", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -901,6 +915,7 @@ func TestQueries(t *testing.T) {
@@ -901,6 +915,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -919,6 +934,7 @@ func TestQueries(t *testing.T) {
@@ -919,6 +934,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -946,6 +962,7 @@ func TestQueries(t *testing.T) {
@@ -946,6 +962,7 @@ func TestQueries(t *testing.T) {
|
|
|
|
|
vars: map[string]string{"foo": ""}, |
|
|
|
|
host: "", |
|
|
|
|
path: "", |
|
|
|
|
query: "foo=", |
|
|
|
|
shouldMatch: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
@ -1537,6 +1554,7 @@ func testRoute(t *testing.T, test routeTest) {
@@ -1537,6 +1554,7 @@ func testRoute(t *testing.T, test routeTest) {
|
|
|
|
|
route := test.route |
|
|
|
|
vars := test.vars |
|
|
|
|
shouldMatch := test.shouldMatch |
|
|
|
|
query := test.query |
|
|
|
|
shouldRedirect := test.shouldRedirect |
|
|
|
|
uri := url.URL{ |
|
|
|
|
Scheme: test.scheme, |
|
|
|
|
@ -1606,6 +1624,13 @@ func testRoute(t *testing.T, test routeTest) {
@@ -1606,6 +1624,13 @@ func testRoute(t *testing.T, test routeTest) {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if query != "" { |
|
|
|
|
u, _ := route.URL(mapToPairs(match.Vars)...) |
|
|
|
|
if query != u.RawQuery { |
|
|
|
|
t.Errorf("(%v) URL query not equal: expected %v, got %v", test.title, query, u.RawQuery) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if shouldRedirect && match.Handler == nil { |
|
|
|
|
t.Errorf("(%v) Did not redirect", test.title) |
|
|
|
|
return |
|
|
|
|
|