作者 tangxuhui

添加test

package dictionary
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() {
Describe("提交数据创建数据字典设置", func() {
Context("提交正确的新字典数据", func() {
It("返回字典数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"dictionaryId": "int",
"dictCode": "string",
"dictName": "string",
"desc": "string",
"isShow": "int",
"dictItems": "array",
}
httpExpect.POST("/dictionarys/").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("dictionaryId").ValueNotEqual("dictionaryId", BeZero())
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM dictionarys WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package dictionary
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/beego/beego/v2/server/web"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego"
)
func TestDictionary(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port Dictionary Correlations Test Case Suite")
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = web.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = AfterSuite(func() {
server.Close()
})
... ...
package dictionary
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 dictionaryId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&dictionaryId),
"INSERT INTO dictionarys (dictionary_id, dict_code, dict_name, desc, is_show, dict_items) VALUES (?, ?, ?, ?, ?, ?) RETURNING dictionary_id",
"testDictionaryId", "testDictCode", "testDictName", "testDesc", "testIsShow", "testDictItems")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据dictionaryId参数返回字典", func() {
Context("传入有效的dictionaryId", func() {
It("返回字典数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/dictionarys/{dictionaryId}").
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 dictionarys WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package dictionary
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 dictionaryId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&dictionaryId),
"INSERT INTO dictionarys (dictionary_id, dict_code, dict_name, desc, is_show, dict_items) VALUES (?, ?, ?, ?, ?, ?) RETURNING dictionary_id",
"testDictionaryId", "testDictCode", "testDictName", "testDesc", "testIsShow", "testDictItems")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数返回字典列表", func() {
Context("传入有效的参数", func() {
It("返回字典数据列表", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/dictionarys/").
WithQuery("offset", "int").
WithQuery("limit", "int").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("count").ValueEqual("count", 1).
ContainsKey("dictionarys").Value("dictionarys").Array()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM dictionarys WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package dictionary
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 dictionaryId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&dictionaryId),
"INSERT INTO dictionarys (dictionary_id, dict_code, dict_name, desc, is_show, dict_items) VALUES (?, ?, ?, ?, ?, ?) RETURNING dictionary_id",
"testDictionaryId", "testDictCode", "testDictName", "testDesc", "testIsShow", "testDictItems")
Expect(err).NotTo(HaveOccurred())
})
Describe("提交数据更新数据字典设置", func() {
Context("提交正确的字典数据", func() {
It("返回更新后的字典数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"dictionaryId": "int",
"dictCode": "string",
"dictName": "string",
"desc": "string",
"isShow": "int",
"dictItems": "array",
}
httpExpect.PUT("/dictionarys/{dictionaryId}").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("dictionaryId").ValueEqual("dictionaryId", dictionaryId)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM dictionarys WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_personal
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 noticePersonalId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&noticePersonalId),
"INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",
"testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")
Expect(err).NotTo(HaveOccurred())
})
Describe("设置消息:共创申请审核通过", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userBaseId": "int64",
"orgId": "int64",
"companyId": "int64",
"creationProjectId": "int64",
"creationProjectName": "string",
"creationProjectNumber": "string",
}
httpExpect.POST("/notice-personal/agree-join-creation-project").
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 notice_personals WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_personal
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 noticePersonalId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&noticePersonalId),
"INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",
"testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")
Expect(err).NotTo(HaveOccurred())
})
Describe("设置消息:共创申请审核通过", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userBaseId": "int64",
"orgId": "int64",
"companyId": "int64",
"creditAccountOrderNum": "string",
"settlementAmount": "string",
"creditAccountId": "int64",
"dividendsEstimateId": "int64",
"dividendsEstimateOrderNumber": "string",
}
httpExpect.POST("/notice-personal/credit-account/dividends-estimate").
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 notice_personals WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_personal
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 noticePersonalId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&noticePersonalId),
"INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",
"testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")
Expect(err).NotTo(HaveOccurred())
})
Describe("设置消息:共创申请审核通过", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userBaseId": "int64",
"orgId": "int64",
"companyId": "int64",
"creditAccountOrderNum": "string",
"settlementAmount": "string",
"creditAccountId": "int64",
"actuallyPaidAmount": "string",
}
httpExpect.POST("/notice-personal/notice-personal/credit-account/payment").
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 notice_personals WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_personal
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 noticePersonalId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&noticePersonalId),
"INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",
"testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")
Expect(err).NotTo(HaveOccurred())
})
Describe("获取消息列表", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"offset": "int64",
"limit": "int64",
"isRead": "int64",
}
httpExpect.POST("/notice-personal/").
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 notice_personals WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_personal
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 noticePersonalId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&noticePersonalId),
"INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",
"testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")
Expect(err).NotTo(HaveOccurred())
})
Describe("设置消息:分红预算消息", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userBaseId": "int64",
"orgId": "int64",
"companyId": "int64",
"creationProjectId": "int64",
"creationProjectName": "string",
"creationContractId": "int64",
"creationContractName": "string",
"creationContractNumber": "string",
"productName": "string",
}
httpExpect.POST("/notice-personal/inform-expected-dividends").
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 notice_personals WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_personal
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 noticePersonalId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&noticePersonalId),
"INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",
"testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")
Expect(err).NotTo(HaveOccurred())
})
Describe("设置消息:共创确认", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userBaseId": "int64",
"orgId": "int64",
"companyId": "int64",
"creationProjectId": "int64",
"creationProjectName": "string",
"creationContractId": "int64",
"creationContractName": "string",
"creationContractNumber": "string",
}
httpExpect.POST("/notice-personal/inform-join-creation-contract").
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 notice_personals WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_personal
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/beego/beego/v2/server/web"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego"
)
func TestNoticePersonal(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port NoticePersonal Correlations Test Case Suite")
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = web.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = AfterSuite(func() {
server.Close()
})
... ...
package notice_personal
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 noticePersonalId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&noticePersonalId),
"INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",
"testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")
Expect(err).NotTo(HaveOccurred())
})
Describe("设置消息:共创申请审核拒绝", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"userBaseId": "int64",
"orgId": "int64",
"companyId": "int64",
"creationProjectId": "int64",
"creationProjectName": "string",
"creationProjectNumber": "string",
}
httpExpect.POST("/notice-personal/refuse-join-creation-project").
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 notice_personals WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
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(&noticeSettingId),
"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("根据noticeSettingId参数返回编排消息通知内容", func() {
Context("传入有效的noticeSettingId", func() {
It("返回编排消息通知内容数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/notice-setting/{Id}").
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())
})
})
... ...
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(&noticeSettingId),
"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)
httpExpect.GET("/notice-setting/").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("count").ValueEqual("count", 1).
ContainsKey("noticeSettings").Value("noticeSettings").Array()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM notice_settings WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package notice_setting
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/beego/beego/v2/server/web"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego"
)
func TestNoticeSetting(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port NoticeSetting Correlations Test Case Suite")
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = web.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = AfterSuite(func() {
server.Close()
})
... ...
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(&noticeSettingId),
"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())
})
})
... ...