unit test for stats.go

This commit is contained in:
hantmac
2019-08-23 20:28:11 +08:00
parent 87f1cebc3b
commit 44e98a56a3
3 changed files with 94 additions and 3 deletions

View File

@@ -11,7 +11,6 @@ import (
"strings"
"testing"
"time"
"ucloudBilling/ucloud/log"
)
var app *gin.Engine
@@ -29,6 +28,7 @@ func init() {
app.GET("/nodes/:id/system", GetSystemInfo) // 节点任务列表
app.DELETE("/nodes/:id", DeleteNode) // 删除节点
//// 爬虫
app.GET("/stats/home",GetHomeStats) // 首页统计数据
// 定时任务
app.GET("/schedules", GetScheduleList) // 定时任务列表
app.GET("/schedules/:id", GetSchedule) // 定时任务详情
@@ -44,7 +44,6 @@ func TestGetNodeList(t *testing.T) {
req, _ := http.NewRequest("GET", "/nodes", nil)
app.ServeHTTP(w, req)
err := json.Unmarshal([]byte(w.Body.String()), &resp)
t.Log(resp.Data)
if err != nil {
t.Fatal("Unmarshal resp failed")
}
@@ -148,7 +147,6 @@ func TestPostNode(t *testing.T) {
var resp Response
body, _ := json.Marshal(newItem)
log.Info(strings.NewReader(string(body)))
var mongoId = "5d429e6c19f7abede924fee2"
w := httptest.NewRecorder()