审查视图

test/integration/beego/auth/phone_auth_reset_password_test.go 1.5 KB
yangfu authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package auth

import (
	"github.com/go-pg/pg/v10"
	"net/http"

	"github.com/gavv/httpexpect"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg"
)

var _ = Describe("重置密码(忘记密码)", func() {
	var Id int64
	BeforeEach(func() {
		_, err := pG.DB.QueryOne(
			pg.Scan(&Id),
18
			"INSERT INTO \"users\".\"user_base\"(\"user_base_id\", \"user_info\", \"account\", \"password\", \"im\", \"related_user\", \"status\", \"created_at\", \"updated_at\") VALUES (999, '{\"phone\": \"phone\", \"userName\": \"string\"}', 'phone', 'string', '{\"accid\": \"\", \"imToken\": \"\", \"csAccountId\": \"\"}', '{4}', 1, '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08') RETURNING user_base_id;",
yangfu authored
19 20 21 22 23 24 25 26
		)
		Expect(err).NotTo(HaveOccurred())
	})
	Describe("重置密码(忘记密码)", func() {
		Context("", func() {
			It("", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				body := map[string]interface{}{
27
					"phone":    "phone",
yangfu authored
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
					"password": "string",
				}
				httpExpect.POST("/auth/reset-password").
					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() {
43
		_, err := pG.DB.Exec("DELETE FROM users.user_base WHERE user_base_id = 999")
yangfu authored
44 45 46
		Expect(err).NotTo(HaveOccurred())
	})
})