role_access_test.go 941 字节
package rbac

import (
	"net/http"

	"github.com/gavv/httpexpect"
	"github.com/go-pg/pg"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	pG "github.com/tiptok/godevp/pkg/infrastructure/pg"
)

var _ = Describe("角色权限", func() {
	var Id int64
	BeforeEach(func() {
		_, err := pG.DB.QueryOne(
			pg.Scan(&Id),
			"INSERT INTO s () VALUES () RETURNING id",
		)
		Expect(err).NotTo(HaveOccurred())
	})
	Describe("角色权限", func() {
		Context("", func() {
			It("", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				httpExpect.GET("/rbacs/roleAccess/{roleId}").
					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 s WHERE true")
		Expect(err).NotTo(HaveOccurred())
	})
})