mirror of https://github.com/gin-gonic/gin.git
fix test and build
This commit is contained in:
parent
9e930b9bdd
commit
3c3526f1f1
|
@ -3,6 +3,7 @@ package gin
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ func BenchmarkManyHandlers(B *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Benchmark5Params(B *testing.B) {
|
func Benchmark5Params(B *testing.B) {
|
||||||
DefaultWriter = newMockWriter()
|
DefaultWriter = os.Stdout
|
||||||
router := New()
|
router := New()
|
||||||
router.Use(func(c *Context) {})
|
router.Use(func(c *Context) {})
|
||||||
router.GET("/param/:param1/:params2/:param3/:param4/:param5", func(c *Context) {})
|
router.GET("/param/:param1/:params2/:param3/:param4/:param5", func(c *Context) {})
|
||||||
|
|
10
gin_test.go
10
gin_test.go
|
@ -217,27 +217,27 @@ func TestListOfRoutes(t *testing.T) {
|
||||||
assertRoutePresent(t, list, RouteInfo{
|
assertRoutePresent(t, list, RouteInfo{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: "/favicon.ico",
|
Path: "/favicon.ico",
|
||||||
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handler_test1$",
|
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
|
||||||
})
|
})
|
||||||
assertRoutePresent(t, list, RouteInfo{
|
assertRoutePresent(t, list, RouteInfo{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handler_test1$",
|
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
|
||||||
})
|
})
|
||||||
assertRoutePresent(t, list, RouteInfo{
|
assertRoutePresent(t, list, RouteInfo{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: "/users/",
|
Path: "/users/",
|
||||||
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handler_test2$",
|
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest2$",
|
||||||
})
|
})
|
||||||
assertRoutePresent(t, list, RouteInfo{
|
assertRoutePresent(t, list, RouteInfo{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: "/users/:id",
|
Path: "/users/:id",
|
||||||
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handler_test1$",
|
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest1$",
|
||||||
})
|
})
|
||||||
assertRoutePresent(t, list, RouteInfo{
|
assertRoutePresent(t, list, RouteInfo{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: "/users/:id",
|
Path: "/users/:id",
|
||||||
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handler_test2$",
|
Handler: "^(.*/vendor/)?github.com/gin-gonic/gin.handlerTest2$",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -298,7 +299,7 @@ func githubConfigRouter(router *Engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGithubAPI(t *testing.T) {
|
func TestGithubAPI(t *testing.T) {
|
||||||
DefaultWriter = newMockWriter()
|
DefaultWriter = os.Stdout
|
||||||
router := Default()
|
router := Default()
|
||||||
githubConfigRouter(router)
|
githubConfigRouter(router)
|
||||||
|
|
||||||
|
@ -357,7 +358,7 @@ func BenchmarkGithub(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkParallelGithub(b *testing.B) {
|
func BenchmarkParallelGithub(b *testing.B) {
|
||||||
DefaultWriter = newMockWriter()
|
DefaultWriter = os.Stdout
|
||||||
router := New()
|
router := New()
|
||||||
githubConfigRouter(router)
|
githubConfigRouter(router)
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ func BenchmarkParallelGithub(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkParallelGithubDefault(b *testing.B) {
|
func BenchmarkParallelGithubDefault(b *testing.B) {
|
||||||
DefaultWriter = newMockWriter()
|
DefaultWriter = os.Stdout
|
||||||
router := Default()
|
router := Default()
|
||||||
githubConfigRouter(router)
|
githubConfigRouter(router)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue