Merge 9e8f29ea5a149059ea092bfd7ec0ec3ea36ba63d into 3f95933c3d8ab010c1454b35b6dd8b534948f928

This commit is contained in:
Sam Heslop 2017-06-05 15:08:34 +00:00 committed by GitHub
commit b72f7cd6c2
5 changed files with 19 additions and 9 deletions

View File

@ -271,7 +271,7 @@ func TestContextHandlerName(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.handlers = HandlersChain{func(c *Context) {}, handlerNameTest}
assert.Regexp(t, "^(.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest$", c.HandlerName())
assert.Regexp(t, "^(.*/vendor/)?github.com/.*?/gin.handlerNameTest$", c.HandlerName())
}
func handlerNameTest(c *Context) {

View File

@ -63,7 +63,7 @@ func TestDebugPrintRoutes(t *testing.T) {
defer teardown()
debugPrintRoute("GET", "/path/to/route/:param", HandlersChain{func(c *Context) {}, handlerNameTest})
assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, w.String())
assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/.*?/gin.handlerNameTest \(2 handlers\)\n$`, w.String())
}
func setup(w io.Writer) {

View File

@ -7,11 +7,13 @@ import (
"net"
"net/http"
"os"
"runtime"
"testing"
"time"
"github.com/stretchr/testify/assert"
"net/http/httptest"
"github.com/stretchr/testify/assert"
)
func testRequest(t *testing.T, url string) {
@ -77,6 +79,10 @@ func TestRunWithPort(t *testing.T) {
}
func TestUnixSocket(t *testing.T) {
if runtime.GOOS == "windows" {
return
}
router := New()
go func() {
@ -101,6 +107,10 @@ func TestUnixSocket(t *testing.T) {
}
func TestBadUnixSocket(t *testing.T) {
if runtime.GOOS == "windows" {
return
}
router := New()
assert.Error(t, router.RunUnix("#/tmp/unix_unit_test"))
}

View File

@ -275,27 +275,27 @@ func TestListOfRoutes(t *testing.T) {
assertRoutePresent(t, list, RouteInfo{
Method: "GET",
Path: "/favicon.ico",
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
Handler: "^(.*/vendor/)?github.com/.*?/gin.handlerTest1$",
})
assertRoutePresent(t, list, RouteInfo{
Method: "GET",
Path: "/",
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
Handler: "^(.*/vendor/)?github.com/.*?/gin.handlerTest1$",
})
assertRoutePresent(t, list, RouteInfo{
Method: "GET",
Path: "/users/",
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest2$",
Handler: "^(.*/vendor/)?github.com/.*?/gin.handlerTest2$",
})
assertRoutePresent(t, list, RouteInfo{
Method: "GET",
Path: "/users/:id",
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
Handler: "^(.*/vendor/)?github.com/.*?/gin.handlerTest1$",
})
assertRoutePresent(t, list, RouteInfo{
Method: "POST",
Path: "/users/:id",
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest2$",
Handler: "^(.*/vendor/)?github.com/.*?/gin.handlerTest2$",
})
}

View File

@ -78,7 +78,7 @@ func TestFilterFlags(t *testing.T) {
}
func TestFunctionName(t *testing.T) {
assert.Regexp(t, `^(.*/vendor/)?github.com/gin-gonic/gin.somefunction$`, nameOfFunction(somefunction))
assert.Regexp(t, `^(.*/vendor/)?github.com/.*?/gin.somefunction$`, nameOfFunction(somefunction))
}
func somefunction() {