initial api test.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
97b381b748
commit
833befcf1c
|
@ -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)
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue