From d1dbeb02cb6fcf07d3e6ddb49801ebd25df3a821 Mon Sep 17 00:00:00 2001 From: "samuel.heslop@disney.com" Date: Fri, 4 Nov 2016 13:12:09 +0000 Subject: [PATCH 1/2] Ignore Unix Socket tests on windows OS --- gin_integration_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gin_integration_test.go b/gin_integration_test.go index 85216970..18b24896 100644 --- a/gin_integration_test.go +++ b/gin_integration_test.go @@ -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")) } From 9e8f29ea5a149059ea092bfd7ec0ec3ea36ba63d Mon Sep 17 00:00:00 2001 From: "samuel.heslop@disney.com" Date: Fri, 4 Nov 2016 13:14:53 +0000 Subject: [PATCH 2/2] Use regex for orgname in 'nameOf' methods --- context_test.go | 2 +- debug_test.go | 2 +- gin_test.go | 10 +++++----- utils_test.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/context_test.go b/context_test.go index 97d4957c..1341d150 100644 --- a/context_test.go +++ b/context_test.go @@ -154,7 +154,7 @@ func TestContextHandlerName(t *testing.T) { c, _, _ := CreateTestContext() 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) { diff --git a/debug_test.go b/debug_test.go index deceaa6e..284cae9f 100644 --- a/debug_test.go +++ b/debug_test.go @@ -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) { diff --git a/gin_test.go b/gin_test.go index cc24bc92..ad21235a 100644 --- a/gin_test.go +++ b/gin_test.go @@ -217,27 +217,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$", }) } diff --git a/utils_test.go b/utils_test.go index 599172fe..b2581568 100644 --- a/utils_test.go +++ b/utils_test.go @@ -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() {