get_notice_setting_test.go 1.4 KB
package notice_setting

import (
	"net/http"
	"time"

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

var _ = Describe("返回编排消息通知内容", func() {
	var noticeSettingId int64
	BeforeEach(func() {
		_, err := pG.DB.QueryOne(
			pg.Scan(&noticeSettingId),
			"INSERT INTO notice_settings (company_id, content, is_push, module, module_action, notice_setting_id, org_id,  created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?,  ?, ?, ?) RETURNING notice_setting_id",
			1, "testContent", 1, "testModule", "testModuleAction", 10086, 1110, time.Now(), time.Now(), time.Now())
		Expect(err).NotTo(HaveOccurred())
	})
	Describe("根据noticeSettingId参数返回编排消息通知内容", func() {
		Context("传入有效的noticeSettingId", func() {
			It("返回编排消息通知内容数据", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				httpExpect.GET("/notice-setting/10086").
					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 notice_settings WHERE true")
		Expect(err).NotTo(HaveOccurred())
	})
})