...
|
...
|
@@ -12,16 +12,20 @@ import ( |
|
|
)
|
|
|
|
|
|
var _ = Describe("投入现金", func() {
|
|
|
var (
|
|
|
cashPoolId int64
|
|
|
cash float64
|
|
|
)
|
|
|
BeforeEach(func() {
|
|
|
_, err := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO cash_pools (cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time) VALUES (10001, 312, 0, 10001, 0, 0, 0, 0, '2021-02-23 08:08:17.754862+00:00:00') RETURNING id, cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time",
|
|
|
pg.Scan( &cashPoolId, &cash),
|
|
|
"INSERT INTO cash_pools (cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time",
|
|
|
100, 312, 100, 10001, 0, 0, 0, 0, time.Now)
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
})
|
|
|
Describe("投入现金", func() {
|
|
|
Context("投入现金需要大于已兑换的现金)", func() {
|
|
|
It("返回现金池数据", func() {
|
|
|
Describe("投入现金到现金池", func() {
|
|
|
Context("投入错误的金额", func() {
|
|
|
It("返回现金池错误数据", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"cash": 99,
|
...
|
...
|
@@ -33,8 +37,28 @@ var _ = Describe("投入现金", func() { |
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueNotEqual("code", 0).
|
|
|
ContainsKey("msg").ValueNotEqual("msg", "ok").
|
|
|
ContainsKey("code").ValueEqual("code", 501).
|
|
|
ContainsKey("msg").ValueEqual("msg", "投入的现金值必须大于当前已兑换现金值").
|
|
|
NotContainsKey("data").Value("data").Object()
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
Describe("投入现金到现金池", func() {
|
|
|
Context("投入正确的金额", func() {
|
|
|
It("返回正确现金池数据", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{} {
|
|
|
"cash": 100,
|
|
|
"companyId": 312,
|
|
|
}
|
|
|
httpExpect.POST("/cash-pool/input").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").Value("data").Object()
|
|
|
})
|
|
|
})
|
...
|
...
|
|