create_org_test.go 1.1 KB
package org

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() {
	Describe("提交数据创建组织", func() {
		Context("提交正确的新组织 organization数据", func() {
			It("返回组织 organization数据", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				body := map[string]interface{}{
					"companyId": "int64",
					"orgCode":   "string",
					"orgName":   "string",
					"isOrg":     "int",
					"parentId":  "int64",
				}
				httpExpect.POST("/org/").
					WithJSON(body).
					Expect().
					Status(http.StatusOK).
					JSON().
					Object().
					ContainsKey("code").ValueEqual("code", 0).
					ContainsKey("msg").ValueEqual("msg", "ok").
					ContainsKey("data").Value("data").Object().
					ContainsKey("orgId").ValueNotEqual("orgId", BeZero())
			})
		})
	})
	AfterEach(func() {
		_, err := pG.DB.Exec("DELETE FROM org WHERE true")
		Expect(err).NotTo(HaveOccurred())
	})
})