mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-19 07:38:57 +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{}
|
||||
go func() {
|
||||
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
|
||||
// otherwise the main thread will complete
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
|
||||
assert.Error(t, router.RunServer(service),":8080")
|
||||
testRequest(t, "http://localhost:8080/example")
|
||||
assert.Error(t, router.RunServer(service,":8090"))
|
||||
testRequest(t, "http://localhost:8090/example")
|
||||
}
|
||||
|
||||
func TestRunTLS(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user