|
@@ -30,8 +30,13 @@ var _ = Describe("发布任务", func() { |
|
@@ -30,8 +30,13 @@ var _ = Describe("发布任务", func() { |
30
|
},
|
30
|
},
|
31
|
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
|
31
|
}, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
|
32
|
Expect(err).NotTo(HaveOccurred())
|
32
|
Expect(err).NotTo(HaveOccurred())
|
|
|
33
|
+ _, err1 := pG.DB.QueryOne(
|
|
|
34
|
+ pg.Scan(),
|
|
|
35
|
+ "INSERT INTO employees (id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?)",
|
|
|
36
|
+ 1, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
37
|
+ Expect(err1).NotTo(HaveOccurred())
|
33
|
})
|
38
|
})
|
34
|
- FIt("发布任务成功", func() {
|
39
|
+ It("发布任务成功", func() {
|
35
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
40
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
36
|
body := map[string]interface{}{
|
41
|
body := map[string]interface{}{
|
37
|
"operator": 2499036607974745088,
|
42
|
"operator": 2499036607974745088,
|
|
@@ -47,6 +52,44 @@ var _ = Describe("发布任务", func() { |
|
@@ -47,6 +52,44 @@ var _ = Describe("发布任务", func() { |
47
|
ContainsKey("data").Value("data").Object()
|
52
|
ContainsKey("data").Value("data").Object()
|
48
|
})
|
53
|
})
|
49
|
})
|
54
|
})
|
|
|
55
|
+ Context("任务发起者发布不是待发布的任务", func() {
|
|
|
56
|
+ BeforeEach(func() {
|
|
|
57
|
+ dayAfter, _ := time.ParseDuration("72h")
|
|
|
58
|
+ _, err := pG.DB.QueryOne(
|
|
|
59
|
+ pg.Scan(),
|
|
|
60
|
+ "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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
|
61
|
+ 1, 101, "抢单任务1",1, &domain.EmployeeInfo{
|
|
|
62
|
+ Uid: 2499036607974745088,
|
|
|
63
|
+ }, 3, "null", pg.Array([]string{"口感", "便利", "品牌", "售后服务"}), "面", 1000.00, "验收标准1", "任务描述1", pg.Array([]string{}), true, []*domain.EmployeeInfo{
|
|
|
64
|
+ {
|
|
|
65
|
+ Uid: 2499036607974745077,
|
|
|
66
|
+ },
|
|
|
67
|
+ {
|
|
|
68
|
+ Uid: 2499036607974745066,
|
|
|
69
|
+ },
|
|
|
70
|
+ }, "null", "", pg.Array([]string{}), 2499036607974745099, time.Now(), time.Now().Add(dayAfter))
|
|
|
71
|
+ Expect(err).NotTo(HaveOccurred())
|
|
|
72
|
+ _, err1 := pG.DB.QueryOne(
|
|
|
73
|
+ pg.Scan(),
|
|
|
74
|
+ "INSERT INTO employees (id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?)",
|
|
|
75
|
+ 1, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
76
|
+ Expect(err1).NotTo(HaveOccurred())
|
|
|
77
|
+ })
|
|
|
78
|
+ It("发布任务失败", func() {
|
|
|
79
|
+ httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
80
|
+ body := map[string]interface{}{
|
|
|
81
|
+ "operator": 2499036607974745088,
|
|
|
82
|
+ }
|
|
|
83
|
+ httpExpect.POST("/tasks/1/release").
|
|
|
84
|
+ WithJSON(body).
|
|
|
85
|
+ Expect().
|
|
|
86
|
+ Status(http.StatusOK).
|
|
|
87
|
+ JSON().
|
|
|
88
|
+ Object().
|
|
|
89
|
+ ContainsKey("code").ValueEqual("code", 501).
|
|
|
90
|
+ ContainsKey("msg").ValueEqual("msg", "内部服务出错:进行中的任务不允许重新发布")
|
|
|
91
|
+ })
|
|
|
92
|
+ })
|
50
|
})
|
93
|
})
|
51
|
AfterEach(func() {
|
94
|
AfterEach(func() {
|
52
|
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
|
95
|
_, err := pG.DB.Exec("DELETE FROM tasks WHERE true")
|
|
@@ -55,5 +98,7 @@ var _ = Describe("发布任务", func() { |
|
@@ -55,5 +98,7 @@ var _ = Describe("发布任务", func() { |
55
|
Expect(err1).NotTo(HaveOccurred())
|
98
|
Expect(err1).NotTo(HaveOccurred())
|
56
|
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
|
99
|
_, err2 := pG.DB.Exec("DELETE FROM bidder_infos WHERE true")
|
57
|
Expect(err2).NotTo(HaveOccurred())
|
100
|
Expect(err2).NotTo(HaveOccurred())
|
|
|
101
|
+ _, err3 := pG.DB.Exec("DELETE FROM employees WHERE true")
|
|
|
102
|
+ Expect(err3).NotTo(HaveOccurred())
|
58
|
})
|
103
|
})
|
59
|
}) |
104
|
}) |