un_assgin_role_to_users_test.go 1.4 KB
package role

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() {
	return
	var roleId int64
	BeforeEach(func() {
		_, err := pG.DB.QueryOne(
			pg.Scan(&roleId),
			"INSERT INTO roles (role_id, company_id, org_id, role_type, role_name, access_menus, desc, ext, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING role_id",
			"testRoleId", "testCompanyId", "testOrgId", "testRoleType", "testRoleName", "testAccessMenus", "testDesc", "testExt", "testCreatedAt", "testUpdatedAt")
		Expect(err).NotTo(HaveOccurred())
	})
	Describe("取消用户分配的角色", func() {
		Context("", func() {
			It("", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				body := map[string]interface{}{
					"roleId":  "int64",
					"userIds": "array",
				}
				httpExpect.POST("/role/unassign").
					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 roles WHERE true")
		Expect(err).NotTo(HaveOccurred())
	})
})