update_notice_setting_test.go
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package notice_setting
import (
"net/http"
"github.com/gavv/httpexpect"
. "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(¬iceSettingId),
"INSERT INTO notice_settings (company_id, content, is_push, module, module_action, notice_setting_id, org_id, sys_code, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_setting_id",
"testCompanyId", "testContent", "testIsPush", "testModule", "testModuleAction", "testNoticeSettingId", "testOrgId", "testSysCode", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("提交数据更新编排消息通知内容", func() {
Context("提交正确的编排消息通知内容数据", func() {
It("返回更新后的编排消息通知内容数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"companyId": "int64",
"content": "string",
"isPush": "int",
"module": "string",
"moduleAction": "string",
"noticeSettingId": "int64",
"orgId": "int64",
"sysCode": "string",
"createdAt": "datetime",
"deletedAt": "datetime",
"updatedAt": "datetime",
}
httpExpect.PUT("/notice-setting/{Id}").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("noticeSettingId").ValueEqual("noticeSettingId", noticeSettingId)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM notice_settings WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})