正在显示
5 个修改的文件
包含
137 行增加
和
6 行删除
pkg/domain/service/mutation_cash_pool.go
0 → 100644
1 | package cash_pool | 1 | package cash_pool |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "github.com/go-pg/pg" | ||
4 | "net/http" | 5 | "net/http" |
6 | + "time" | ||
5 | 7 | ||
6 | "github.com/gavv/httpexpect" | 8 | "github.com/gavv/httpexpect" |
7 | . "github.com/onsi/ginkgo" | 9 | . "github.com/onsi/ginkgo" |
@@ -10,21 +12,29 @@ import ( | @@ -10,21 +12,29 @@ import ( | ||
10 | ) | 12 | ) |
11 | 13 | ||
12 | var _ = Describe("投入现金", func() { | 14 | var _ = Describe("投入现金", func() { |
13 | - Describe("投入现金并更新现金池数据", func() { | ||
14 | - Context("提交正确的现金值(>=已兑换的现金)", func() { | 15 | + BeforeEach(func() { |
16 | + _, err := pG.DB.QueryOne( | ||
17 | + pg.Scan(), | ||
18 | + "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", | ||
19 | + 100, 312, 100, 10001, 0, 0, 0, 0, time.Now) | ||
20 | + Expect(err).NotTo(HaveOccurred()) | ||
21 | + }) | ||
22 | + Describe("投入现金", func() { | ||
23 | + Context("投入现金需要大于已兑换的现金)", func() { | ||
15 | It("返回现金池数据", func() { | 24 | It("返回现金池数据", func() { |
16 | httpExpect := httpexpect.New(GinkgoT(), server.URL) | 25 | httpExpect := httpexpect.New(GinkgoT(), server.URL) |
17 | body := map[string]interface{}{ | 26 | body := map[string]interface{}{ |
18 | - "cashAmount": 100, | 27 | + "cash": 99, |
28 | + "companyId": 312, | ||
19 | } | 29 | } |
20 | - httpExpect.POST("/cash_pool/input"). | 30 | + httpExpect.POST("/cash-pool/input"). |
21 | WithJSON(body). | 31 | WithJSON(body). |
22 | Expect(). | 32 | Expect(). |
23 | Status(http.StatusOK). | 33 | Status(http.StatusOK). |
24 | JSON(). | 34 | JSON(). |
25 | Object(). | 35 | Object(). |
26 | - ContainsKey("code").ValueEqual("code", 0). | ||
27 | - ContainsKey("msg").ValueEqual("msg", "ok"). | 36 | + ContainsKey("code").ValueNotEqual("code", 0). |
37 | + ContainsKey("msg").ValueNotEqual("msg", "ok"). | ||
28 | ContainsKey("data").Value("data").Object() | 38 | ContainsKey("data").Value("data").Object() |
29 | }) | 39 | }) |
30 | }) | 40 | }) |
1 | +/** | ||
2 | + @author: stevechan | ||
3 | + @date: 2021/2/23 | ||
4 | + @note: | ||
5 | +**/ | ||
6 | + | ||
7 | +package cash_pool | ||
8 | + | ||
9 | +import ( | ||
10 | + "github.com/go-pg/pg" | ||
11 | + "net/http" | ||
12 | + "time" | ||
13 | + | ||
14 | + "github.com/gavv/httpexpect" | ||
15 | + . "github.com/onsi/ginkgo" | ||
16 | + . "github.com/onsi/gomega" | ||
17 | + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg" | ||
18 | +) | ||
19 | + | ||
20 | +var _ = Describe("返回现金池数据", func() { | ||
21 | + BeforeEach(func() { | ||
22 | + _, err := pG.DB.QueryOne( | ||
23 | + pg.Scan(), | ||
24 | + "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", | ||
25 | + 100, 312, 100, 10001, 0, 0, 0, 0, time.Now) | ||
26 | + Expect(err).NotTo(HaveOccurred()) | ||
27 | + }) | ||
28 | + Describe("根据公司id返回现金池数据", func() { | ||
29 | + Context("传入有效的公司id", func() { | ||
30 | + It("返回现金池数据", func() { | ||
31 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
32 | + httpExpect.GET("/cash-pool/cash-pool?companyId=312"). | ||
33 | + Expect(). | ||
34 | + Status(http.StatusOK). | ||
35 | + JSON(). | ||
36 | + Object(). | ||
37 | + ContainsKey("code").ValueNotEqual("code", 0). | ||
38 | + ContainsKey("msg").ValueNotEqual("msg", "ok"). | ||
39 | + ContainsKey("data").Value("data").Object() | ||
40 | + }) | ||
41 | + }) | ||
42 | + }) | ||
43 | + AfterEach(func() { | ||
44 | + _, err := pG.DB.Exec("DELETE FROM cash_pools WHERE true") | ||
45 | + Expect(err).NotTo(HaveOccurred()) | ||
46 | + }) | ||
47 | +}) |
@@ -5,3 +5,32 @@ | @@ -5,3 +5,32 @@ | ||
5 | **/ | 5 | **/ |
6 | 6 | ||
7 | package exchange_activities | 7 | package exchange_activities |
8 | + | ||
9 | +import ( | ||
10 | + "github.com/onsi/ginkgo" | ||
11 | + "github.com/onsi/gomega" | ||
12 | + "net/http" | ||
13 | + "net/http/httptest" | ||
14 | + "testing" | ||
15 | + | ||
16 | + "github.com/astaxie/beego" | ||
17 | + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg" | ||
18 | + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego" | ||
19 | +) | ||
20 | + | ||
21 | +func TestConfig(t *testing.T) { | ||
22 | + gomega.RegisterFailHandler(ginkgo.Fail) | ||
23 | + ginkgo.RunSpecs(t, "Beego Port Exchange Activities Correlations Test Case Suite") | ||
24 | +} | ||
25 | + | ||
26 | +var handler http.Handler | ||
27 | +var server *httptest.Server | ||
28 | + | ||
29 | +var _ = ginkgo.BeforeSuite(func() { | ||
30 | + handler = beego.BeeApp.Handlers | ||
31 | + server = httptest.NewServer(handler) | ||
32 | +}) | ||
33 | + | ||
34 | +var _ = ginkgo.AfterSuite(func() { | ||
35 | + server.Close() | ||
36 | +}) |
@@ -5,3 +5,32 @@ | @@ -5,3 +5,32 @@ | ||
5 | **/ | 5 | **/ |
6 | 6 | ||
7 | package exchange_list | 7 | package exchange_list |
8 | + | ||
9 | +import ( | ||
10 | + "github.com/onsi/ginkgo" | ||
11 | + "github.com/onsi/gomega" | ||
12 | + "net/http" | ||
13 | + "net/http/httptest" | ||
14 | + "testing" | ||
15 | + | ||
16 | + "github.com/astaxie/beego" | ||
17 | + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg" | ||
18 | + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego" | ||
19 | +) | ||
20 | + | ||
21 | +func TestConfig(t *testing.T) { | ||
22 | + gomega.RegisterFailHandler(ginkgo.Fail) | ||
23 | + ginkgo.RunSpecs(t, "Beego Port Exchange List Correlations Test Case Suite") | ||
24 | +} | ||
25 | + | ||
26 | +var handler http.Handler | ||
27 | +var server *httptest.Server | ||
28 | + | ||
29 | +var _ = ginkgo.BeforeSuite(func() { | ||
30 | + handler = beego.BeeApp.Handlers | ||
31 | + server = httptest.NewServer(handler) | ||
32 | +}) | ||
33 | + | ||
34 | +var _ = ginkgo.AfterSuite(func() { | ||
35 | + server.Close() | ||
36 | +}) |
-
请 注册 或 登录 后发表评论