get_cash_pool_test.go
1.4 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
/**
@author: stevechan
@date: 2021/2/23
@note:
**/
package cash_pool
import (
"github.com/go-pg/pg"
"net/http"
"time"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
)
var _ = Describe("返回现金池数据", func() {
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",
100, 312, 100, 10001, 0, 0, 0, 0, time.Now)
Expect(err).NotTo(HaveOccurred())
})
Describe("根据公司id返回现金池数据", func() {
Context("传入有效的公司id", func() {
It("返回现金池数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/cash-pool/cash-pool?companyId=312").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueNotEqual("code", 0).
ContainsKey("msg").ValueNotEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cash_pools WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})