batch_delete_menu_test.go 1.4 KB
package menu

import (
	"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 menuId int64
	BeforeEach(func() {
		_, err := pG.DB.QueryOne(
			pg.Scan(&menuId),
			"INSERT INTO menus (menu_id, parent_id, menu_name, code, access_code, menu_type, icon, sort, remark, category, parent_path, enable_status, is_publish) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING menu_id",
			"testMenuId", "testParentId", "testMenuName", "testCode", "testAccessCode", "testMenuType", "testIcon", "testSort", "testRemark", "testCategory", "testParentPath", "testEnableStatus", "testIsPublish")
		Expect(err).NotTo(HaveOccurred())
	})
	Describe("批量删除菜单", func() {
		Context("", func() {
			It("", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				body := map[string]interface{}{
					"menuIds": "array",
				}
				httpExpect.POST("/menu/batch-delete").
					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 menus WHERE true")
		Expect(err).NotTo(HaveOccurred())
	})
})