person_su_money_statistics_test.go
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package statistics
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"net/http"
"time"
"github.com/gavv/httpexpect"
"github.com/go-pg/pg"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
)
var _ = Describe("获取个人素币统计", func() {
var suMoneyTransactionRecordId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&suMoneyTransactionRecordId),
"INSERT INTO su_money_transaction_records (id, record_type, employee, su_money, operator, record_description, create_time) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id",
1, 2, &domain.EmployeeInfo{
Uid: 2499036607974745088,
}, 1000.00, &domain.EmployeeInfo{
Uid: 2499036607974745099,
}, "testRecordDescription", time.Now().AddDate(0, 0, -1))
Expect(err).NotTo(HaveOccurred())
_, err2 := pG.DB.QueryOne(
pg.Scan(),
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
2, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 1000)
Expect(err2).NotTo(HaveOccurred())
})
Describe("获取个人素币统计", func() {
Context("请求获取个人素币统计", func() {
It("返回个人素币统计", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"uid": 2499036607974745088,
}
httpExpect.POST("/statistics/person-su-money").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM su_money_transaction_records WHERE true")
Expect(err).NotTo(HaveOccurred())
_, err1 := pG.DB.Exec("DELETE FROM employees WHERE true")
Expect(err1).NotTo(HaveOccurred())
})
})