initial api test.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-04-01 00:35:53 +08:00
parent 97b381b748
commit 833befcf1c
1 changed files with 31 additions and 0 deletions

31
gorush/server_test.go Normal file
View File

@ -0,0 +1,31 @@
package gopush
import (
"github.com/appleboy/gofight"
"github.com/buger/jsonparser"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func initTest() {
gin.SetMode(gin.TestMode)
PushConf = BuildDefaultPushConf()
}
func TestGinHelloWorld(t *testing.T) {
initTest()
r := gofight.New()
r.GET("/").
Run(GetMainEngine(), func(r gofight.HttpResponse, rq gofight.HttpRequest) {
data := []byte(r.Body.String())
value, _ := jsonparser.GetString(data, "text")
assert.Equal(t, "Welcome to notification server.", value)
assert.Equal(t, http.StatusOK, r.Code)
})
}