|
|
package task
|
|
|
|
|
|
import (
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
"net/http"
|
|
|
"time"
|
|
|
|
|
|
"github.com/gavv/httpexpect"
|
|
|
"github.com/go-pg/pg"
|
...
|
...
|
@@ -11,32 +13,55 @@ import ( |
|
|
)
|
|
|
|
|
|
var _ = Describe("返回任务列表", func() {
|
|
|
var taskId int64
|
|
|
BeforeEach(func() {
|
|
|
dayAfter, _ := time.ParseDuration("72h")
|
|
|
_, err := pG.DB.QueryOne(
|
|
|
pg.Scan(&taskId),
|
|
|
"INSERT INTO tasks (task_id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, rob_info, bid_info, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
|
|
|
"testTaskId", "testCompanyId", "testTaskName", "testTaskType", "testSponsor", "testTaskStatus", "testReferenceResource", "testCustomerValue", "testTaskNature", "testSuMoney", "testAcceptanceStandard", "testTaskDescription", "testTaskPictureUrls", "testIsRewardTake", "testRobInfo", "testBidInfo", "testParticipators", "testTaskPercentage", "testSolveReport", "testSolvePictureUrls", "testCreateTime", "testReleaseTime")
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
_, err1 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
2, 101, "抢单任务2", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
|
|
|
Expect(err1).NotTo(HaveOccurred())
|
|
|
_, err11 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO bid_infos (id, task_id) VALUES (?, ?)",
|
|
|
1, 2)
|
|
|
Expect(err11).NotTo(HaveOccurred())
|
|
|
_, err22 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO bidder_infos (id, bid_info_id, task_id) VALUES (?, ?, ?)",
|
|
|
1, 1, 2)
|
|
|
Expect(err22).NotTo(HaveOccurred())
|
|
|
_, err2 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
3, 102, "抢单任务1", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
|
|
|
Expect(err2).NotTo(HaveOccurred())
|
|
|
_, err3 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO tasks (id, company_id, task_name, task_type, sponsor, task_status, reference_resource, customer_value, task_nature, su_money, acceptance_standard, task_description, task_picture_urls, is_reward_take, participators, task_percentage, solve_report, solve_picture_urls, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
4, 101, "抢单任务1", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 1, "null", pg.Array([]string{"口感", "便利", "品牌"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, "null", "null", "", pg.Array([]string{}), time.Now(), time.Now().Add(dayAfter))
|
|
|
Expect(err3).NotTo(HaveOccurred())
|
|
|
})
|
|
|
Describe("根据参数返回任务列表", func() {
|
|
|
Context("传入有效的参数", func() {
|
|
|
It("返回任务数据列表", func() {
|
|
|
It("返回指定companyId公司的任务数据列表", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
httpExpect.GET("/tasks/").
|
|
|
WithQuery("companyId", "int64").
|
|
|
WithQuery("sponsor", "int64").
|
|
|
WithQuery("taskContentMatch", "string").
|
|
|
WithQuery("taskType", "int").
|
|
|
WithQuery("taskStatus", "int").
|
|
|
WithQuery("customerValue", "string").
|
|
|
WithQuery("taskNature", "string").
|
|
|
WithQuery("isRewardTake", "boolean").
|
|
|
WithQuery("bidTimeMatch", "int").
|
|
|
WithQuery("receiver", "int64").
|
|
|
WithQuery("participator", "int64").
|
|
|
WithQuery("offset", "int").
|
|
|
WithQuery("limit", "int").
|
|
|
WithQuery("companyId", 101).
|
|
|
WithQuery("offset", 0).
|
|
|
WithQuery("limit", 20).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
...
|
...
|
@@ -44,7 +69,33 @@ var _ = Describe("返回任务列表", func() { |
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").Value("data").Object().
|
|
|
ContainsKey("count").ValueEqual("count", 1).
|
|
|
ContainsKey("count").ValueEqual("count", 3).
|
|
|
ContainsKey("tasks").Value("tasks").Array()
|
|
|
})
|
|
|
It("返回指定companyId公司的任务数据列表", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
httpExpect.GET("/tasks/").
|
|
|
WithQuery("companyId", 101).
|
|
|
//WithQuery("sponsor", "int64").
|
|
|
//WithQuery("taskContentMatch", "string").
|
|
|
//WithQuery("taskType", "int").
|
|
|
//WithQuery("taskStatus", "int").
|
|
|
//WithQuery("customerValue", "string").
|
|
|
//WithQuery("taskNature", "string").
|
|
|
//WithQuery("isRewardTake", "boolean").
|
|
|
//WithQuery("bidTimeMatch", "int").
|
|
|
//WithQuery("receiver", "int64").
|
|
|
//WithQuery("participator", "int64").
|
|
|
WithQuery("offset", 0).
|
|
|
WithQuery("limit", 20).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").Value("data").Object().
|
|
|
ContainsKey("count").ValueEqual("count", 3).
|
|
|
ContainsKey("tasks").Value("tasks").Array()
|
|
|
})
|
|
|
})
|
...
|
...
|
@@ -52,5 +103,9 @@ var _ = Describe("返回任务列表", func() { |
|
|
AfterEach(func() {
|
|
|
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
_, err1 := pG.DB.Exec("DELETE FROM bid_infos WHERE true")
|
|
|
Expect(err1).NotTo(HaveOccurred())
|
|
|
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
|
|
|
Expect(err2).NotTo(HaveOccurred())
|
|
|
})
|
|
|
}) |
...
|
...
|
|