mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-19 15:57:48 +08:00
feat(gin,runserver): fix RunServer test
This commit is contained in:
parent
5f6cd32d8e
commit
72be513b9f
@ -60,14 +60,14 @@ func TestRunServer(t *testing.T) {
|
|||||||
service := &http.Server{}
|
service := &http.Server{}
|
||||||
go func() {
|
go func() {
|
||||||
router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
|
router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
|
||||||
assert.NoError(t, router.RunServer(service),":8080")
|
assert.NoError(t, router.RunServer(service,":8090"))
|
||||||
}()
|
}()
|
||||||
// have to wait for the goroutine to start and run the server
|
// have to wait for the goroutine to start and run the server
|
||||||
// otherwise the main thread will complete
|
// otherwise the main thread will complete
|
||||||
time.Sleep(5 * time.Millisecond)
|
time.Sleep(5 * time.Millisecond)
|
||||||
|
|
||||||
assert.Error(t, router.RunServer(service),":8080")
|
assert.Error(t, router.RunServer(service,":8090"))
|
||||||
testRequest(t, "http://localhost:8080/example")
|
testRequest(t, "http://localhost:8090/example")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunTLS(t *testing.T) {
|
func TestRunTLS(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user