|
|
package exchange_list
|
|
|
|
|
|
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() {
|
|
|
var activityId int64
|
|
|
BeforeEach(func() {
|
|
|
_, err1 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
|
|
|
1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 100.00)
|
|
|
Expect(err1).NotTo(HaveOccurred())
|
|
|
_, err2 := pG.DB.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
|
|
|
2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
|
|
|
Expect(err2).NotTo(HaveOccurred())
|
|
|
_, err3 := pG.DB.QueryOne(
|
|
|
pg.Scan(&activityId),
|
|
|
"INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
|
|
|
101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
|
|
|
Expect(err3).NotTo(HaveOccurred())
|
|
|
})
|
|
|
Describe("提交数据创建素币兑换清单", func() {
|
|
|
Context("提交正确的新建素币兑换清单数据", func() {
|
|
|
It("返回素币兑换清单数据", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{} {
|
|
|
"uid": 2499036607974745088,
|
|
|
"exchangeCashActivityId": activityId,
|
|
|
"exchangedSuMoney": 1.13,
|
|
|
"operator": 2499036607974745099,
|
|
|
}
|
|
|
httpExpect.POST("/cash-pool/activity/exchange-list").
|
|
|
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 exchange_cash_person_lists WHERE true")
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
})
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|