fix testing

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2017-03-15 10:24:27 +08:00
parent 05f0f31078
commit 110a397f57
3 changed files with 15 additions and 15 deletions

View File

@ -12,7 +12,7 @@ git:
install: install:
- go get -v github.com/kardianos/govendor - go get -v github.com/kardianos/govendor
- govendor sync - govendor sync
- go get -u https://github.com/campoy/embedmd - go get -u github.com/campoy/embedmd
script: script:
- embedmd -d README.md - embedmd -d README.md

View File

@ -1,5 +1,4 @@
# Gin Web Framework
#Gin Web Framework
<img align="right" src="https://raw.githubusercontent.com/gin-gonic/gin/master/logo.jpg"> <img align="right" src="https://raw.githubusercontent.com/gin-gonic/gin/master/logo.jpg">
[![Build Status](https://travis-ci.org/gin-gonic/gin.svg)](https://travis-ci.org/gin-gonic/gin) [![Build Status](https://travis-ci.org/gin-gonic/gin.svg)](https://travis-ci.org/gin-gonic/gin)
@ -16,6 +15,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi
```sh ```sh
$ cat test.go $ cat test.go
``` ```
```go ```go
package main package main

View File

@ -115,17 +115,17 @@ func TestWithHttptestWithAutoSelectedPort(t *testing.T) {
testRequest(t, ts.URL+"/example") testRequest(t, ts.URL+"/example")
} }
func TestWithHttptestWithSpecifiedPort(t *testing.T) { // func TestWithHttptestWithSpecifiedPort(t *testing.T) {
router := New() // router := New()
router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") }) // router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
l, _ := net.Listen("tcp", ":8033") // l, _ := net.Listen("tcp", ":8033")
ts := httptest.Server{ // ts := httptest.Server{
Listener: l, // Listener: l,
Config: &http.Server{Handler: router}, // Config: &http.Server{Handler: router},
} // }
ts.Start() // ts.Start()
defer ts.Close() // defer ts.Close()
testRequest(t, "http://localhost:8033/example") // testRequest(t, "http://localhost:8033/example")
} // }