cash_input_test.go 930 字节
package cash_pool

import (
	"net/http"

	"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() {
	Describe("投入现金并更新现金池数据", func() {
		Context("提交正确的现金值(>=已兑换的现金)", func() {
			It("返回现金池数据", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				body := map[string]interface{}{
					"cashAmount": 100,
				}
				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()
			})
		})
	})
	AfterEach(func() {
		_, err := pG.DB.Exec("DELETE FROM ")
		Expect(err).NotTo(HaveOccurred())
	})
})