Merge pull request #361 from hantmac/develop

Update test cases
This commit is contained in:
Marvin Zhang
2019-12-15 12:29:13 +08:00
committed by GitHub
2 changed files with 11 additions and 6 deletions

View File

@@ -10,12 +10,15 @@ import (
"time"
)
var NodeIdss = []bson.ObjectId{bson.ObjectIdHex("5d429e6c19f7abede924fee2"),
bson.ObjectIdHex("5d429e6c19f7abede924fee1")}
var scheduleList = []model.Schedule{
{
Id: bson.ObjectId("5d429e6c19f7abede924fee2"),
Name: "test schedule",
SpiderId: "123",
NodeId: bson.ObjectId("5d429e6c19f7abede924fee2"),
NodeIds: NodeIdss,
Cron: "***1*",
EntryId: 10,
// 前端展示
@@ -29,7 +32,7 @@ var scheduleList = []model.Schedule{
Id: bson.ObjectId("xx429e6c19f7abede924fee2"),
Name: "test schedule2",
SpiderId: "234",
NodeId: bson.ObjectId("5d429e6c19f7abede924fee2"),
NodeIds: NodeIdss,
Cron: "***1*",
EntryId: 10,
// 前端展示
@@ -100,8 +103,10 @@ func PutSchedule(c *gin.Context) {
}
// 如果node_id为空则置为空ObjectId
if item.NodeId == "" {
item.NodeId = bson.ObjectIdHex(constants.ObjectIdNull)
for _, NodeId := range item.NodeIds {
if NodeId == "" {
NodeId = bson.ObjectIdHex(constants.ObjectIdNull)
}
}
c.JSON(http.StatusOK, Response{

View File

@@ -75,7 +75,7 @@ func TestPostSchedule(t *testing.T) {
Id: bson.ObjectIdHex("5d429e6c19f7abede924fee2"),
Name: "test schedule",
SpiderId: bson.ObjectIdHex("5d429e6c19f7abede924fee2"),
NodeId: bson.ObjectIdHex("5d429e6c19f7abede924fee2"),
NodeIds: NodeIdss,
Cron: "***1*",
EntryId: 10,
// 前端展示
@@ -112,7 +112,7 @@ func TestPutSchedule(t *testing.T) {
Id: bson.ObjectIdHex("5d429e6c19f7abede924fee2"),
Name: "test schedule",
SpiderId: bson.ObjectIdHex("5d429e6c19f7abede924fee2"),
NodeId: bson.ObjectIdHex("5d429e6c19f7abede924fee2"),
NodeIds: NodeIdss,
Cron: "***1*",
EntryId: 10,
// 前端展示