...
|
...
|
@@ -21,7 +21,14 @@ var _ = Describe("发布任务", func() { |
|
|
"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, receiver_uid, 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, []*domain.EmployeeInfo{
|
|
|
}, 1, &domain.ReferenceResource{
|
|
|
ReferenceResourceType: 1,
|
|
|
ReferenceResourceItems: []*domain.ReferenceResourceItem{
|
|
|
{
|
|
|
ReferenceResourceId: 4,
|
|
|
},
|
|
|
},
|
|
|
}, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
|
|
|
{
|
|
|
Uid: 2499036607974745077,
|
|
|
},
|
...
|
...
|
@@ -59,7 +66,7 @@ var _ = Describe("发布任务", func() { |
|
|
_, err := 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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
1, 101, "抢单任务1",1, &domain.EmployeeInfo{
|
|
|
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
|
|
|
{
|
...
|
...
|
@@ -91,6 +98,72 @@ var _ = Describe("发布任务", func() { |
|
|
ContainsKey("msg").ValueEqual("msg", "内部服务出错:进行中的任务不允许重新发布")
|
|
|
})
|
|
|
})
|
|
|
Context("发布资源已经被引用的的任务", func() {
|
|
|
BeforeEach(func() {
|
|
|
dayAfter, _ := time.ParseDuration("72h")
|
|
|
_, err := 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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
1, 101, "抢单任务1", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 2, &domain.ReferenceResource{
|
|
|
ReferenceResourceType: 1,
|
|
|
ReferenceResourceItems: []*domain.ReferenceResourceItem{
|
|
|
{
|
|
|
ReferenceResourceId: 4,
|
|
|
},
|
|
|
},
|
|
|
}, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
|
|
|
{
|
|
|
Uid: 2499036607974745077,
|
|
|
},
|
|
|
{
|
|
|
Uid: 2499036607974745066,
|
|
|
},
|
|
|
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
_, err1 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO employees (id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?)",
|
|
|
1, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
Expect(err1).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, receiver_uid, create_time, release_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
2, 101, "抢单任务1", 1, &domain.EmployeeInfo{
|
|
|
Uid: 2499036607974745088,
|
|
|
}, 2, &domain.ReferenceResource{
|
|
|
ReferenceResourceType: 1,
|
|
|
ReferenceResourceItems: []*domain.ReferenceResourceItem{
|
|
|
{
|
|
|
ReferenceResourceId: 4,
|
|
|
},
|
|
|
},
|
|
|
}, pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
|
|
|
{
|
|
|
Uid: 2499036607974745077,
|
|
|
},
|
|
|
{
|
|
|
Uid: 2499036607974745066,
|
|
|
},
|
|
|
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
|
|
|
Expect(err2).NotTo(HaveOccurred())
|
|
|
})
|
|
|
It("发布任务失败", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"operator": 2499036607974745088,
|
|
|
}
|
|
|
httpExpect.POST("/tasks/1/release").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 501).
|
|
|
ContainsKey("msg").ValueEqual("msg", "内部服务出错:问题资源已经被引用,发布任务失败")
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
AfterEach(func() {
|
|
|
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
|
...
|
...
|
|