Updates tree.go + fixes + unit tests

This commit is contained in:
Manu Mtz-Almeida
2015-05-05 16:37:33 +02:00
parent 295201dad2
commit f212ae7728
5 changed files with 113 additions and 25 deletions

View File

@ -357,7 +357,7 @@ func TestTreeDoubleWildcard(t *testing.T) {
tree.addRoute(route, nil)
})
if rs, ok := recv.(string); !ok || rs != panicMsg {
if rs, ok := recv.(string); !ok || !strings.HasPrefix(rs, panicMsg) {
t.Fatalf(`"Expected panic "%s" for route '%s', got "%v"`, panicMsg, route, recv)
}
}
@ -594,15 +594,15 @@ func TestTreeInvalidNodeType(t *testing.T) {
recv := catchPanic(func() {
tree.getValue("/test", nil)
})
if rs, ok := recv.(string); !ok || rs != "Invalid node type" {
t.Fatalf(`Expected panic "Invalid node type", got "%v"`, recv)
if rs, ok := recv.(string); !ok || rs != "invalid node type" {
t.Fatalf(`Expected panic "invalid node type", got "%v"`, recv)
}
// case-insensitive lookup
recv = catchPanic(func() {
tree.findCaseInsensitivePath("/test", true)
})
if rs, ok := recv.(string); !ok || rs != "Invalid node type" {
t.Fatalf(`Expected panic "Invalid node type", got "%v"`, recv)
if rs, ok := recv.(string); !ok || rs != "invalid node type" {
t.Fatalf(`Expected panic "invalid node type", got "%v"`, recv)
}
}