正在显示
7 个修改的文件
包含
175 行增加
和
4 行删除
| @@ -27,6 +27,9 @@ func init() { | @@ -27,6 +27,9 @@ func init() { | ||
| 27 | if !constant.DISABLE_CREATE_TABLE { | 27 | if !constant.DISABLE_CREATE_TABLE { |
| 28 | tables := []interface{}{ | 28 | tables := []interface{}{ |
| 29 | &models.Dictionary{}, | 29 | &models.Dictionary{}, |
| 30 | + &models.NoticePersonal{}, | ||
| 31 | + &models.NoticeSetting{}, | ||
| 32 | + &models.SystemSetting{}, | ||
| 30 | } | 33 | } |
| 31 | for _, model := range tables { | 34 | for _, model := range tables { |
| 32 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | 35 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
| @@ -23,8 +23,8 @@ var _ = Describe("返回数据字典设置列表", func() { | @@ -23,8 +23,8 @@ var _ = Describe("返回数据字典设置列表", func() { | ||
| 23 | It("返回字典数据列表", func() { | 23 | It("返回字典数据列表", func() { |
| 24 | httpExpect := httpexpect.New(GinkgoT(), server.URL) | 24 | httpExpect := httpexpect.New(GinkgoT(), server.URL) |
| 25 | httpExpect.GET("/dictionarys/"). | 25 | httpExpect.GET("/dictionarys/"). |
| 26 | - WithQuery("offset", "int"). | ||
| 27 | - WithQuery("limit", "int"). | 26 | + WithQuery("offset", "string"). |
| 27 | + WithQuery("limit", "string"). | ||
| 28 | Expect(). | 28 | Expect(). |
| 29 | Status(http.StatusOK). | 29 | Status(http.StatusOK). |
| 30 | JSON(). | 30 | JSON(). |
| @@ -24,8 +24,8 @@ var _ = Describe("获取消息列表", func() { | @@ -24,8 +24,8 @@ var _ = Describe("获取消息列表", func() { | ||
| 24 | httpExpect := httpexpect.New(GinkgoT(), server.URL) | 24 | httpExpect := httpexpect.New(GinkgoT(), server.URL) |
| 25 | body := map[string]interface{}{ | 25 | body := map[string]interface{}{ |
| 26 | "userId": "int64", | 26 | "userId": "int64", |
| 27 | - "offset": "int64", | ||
| 28 | - "limit": "int64", | 27 | + "pageIndex": "int", |
| 28 | + "pageSize": "int", | ||
| 29 | "isRead": "int64", | 29 | "isRead": "int64", |
| 30 | } | 30 | } |
| 31 | httpExpect.POST("/notice-personal/"). | 31 | httpExpect.POST("/notice-personal/"). |
| 1 | +package system_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + . "github.com/onsi/ginkgo" | ||
| 8 | + . "github.com/onsi/gomega" | ||
| 9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +var _ = Describe("返回用户的系统设置", func() { | ||
| 13 | + var systemSettingId int64 | ||
| 14 | + BeforeEach(func() { | ||
| 15 | + _, err := pG.DB.QueryOne( | ||
| 16 | + pg.Scan(&systemSettingId), | ||
| 17 | + "INSERT INTO system_settings (company_id, control_level, description, setting_code, setting_name, system_setting_id, value, value_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING system_setting_id", | ||
| 18 | + "testCompanyId", "testControlLevel", "testDescription", "testSettingCode", "testSettingName", "testSystemSettingId", "testValue", "testValueType") | ||
| 19 | + Expect(err).NotTo(HaveOccurred()) | ||
| 20 | + }) | ||
| 21 | + Describe("根据systemSettingId参数返回系统参数设置", func() { | ||
| 22 | + Context("传入有效的systemSettingId", func() { | ||
| 23 | + It("返回系统参数设置数据", func() { | ||
| 24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 25 | + body := map[string]interface{}{ | ||
| 26 | + "settingCode": "string", | ||
| 27 | + "companyId": "int64", | ||
| 28 | + } | ||
| 29 | + httpExpect.POST("/system-settings/get"). | ||
| 30 | + WithJSON(body). | ||
| 31 | + Expect(). | ||
| 32 | + Status(http.StatusOK). | ||
| 33 | + JSON(). | ||
| 34 | + Object(). | ||
| 35 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 36 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 37 | + ContainsKey("data").Value("data").Object() | ||
| 38 | + }) | ||
| 39 | + }) | ||
| 40 | + }) | ||
| 41 | + AfterEach(func() { | ||
| 42 | + _, err := pG.DB.Exec("DELETE FROM system_settings WHERE true") | ||
| 43 | + Expect(err).NotTo(HaveOccurred()) | ||
| 44 | + }) | ||
| 45 | +}) |
| 1 | +package system_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + . "github.com/onsi/ginkgo" | ||
| 8 | + . "github.com/onsi/gomega" | ||
| 9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +var _ = Describe("返回用户的系统设置列表", func() { | ||
| 13 | + var systemSettingId int64 | ||
| 14 | + BeforeEach(func() { | ||
| 15 | + _, err := pG.DB.QueryOne( | ||
| 16 | + pg.Scan(&systemSettingId), | ||
| 17 | + "INSERT INTO system_settings (company_id, control_level, description, setting_code, setting_name, system_setting_id, value, value_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING system_setting_id", | ||
| 18 | + "testCompanyId", "testControlLevel", "testDescription", "testSettingCode", "testSettingName", "testSystemSettingId", "testValue", "testValueType") | ||
| 19 | + Expect(err).NotTo(HaveOccurred()) | ||
| 20 | + }) | ||
| 21 | + Describe("根据参数返回系统参数设置列表", func() { | ||
| 22 | + Context("传入有效的参数", func() { | ||
| 23 | + It("返回系统参数设置数据列表", func() { | ||
| 24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 25 | + body := map[string]interface{}{ | ||
| 26 | + "companyId": "int64", | ||
| 27 | + "settingCode": "string", | ||
| 28 | + } | ||
| 29 | + httpExpect.POST("/system-settings/search"). | ||
| 30 | + WithJSON(body). | ||
| 31 | + Expect(). | ||
| 32 | + Status(http.StatusOK). | ||
| 33 | + JSON(). | ||
| 34 | + Object(). | ||
| 35 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 36 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 37 | + ContainsKey("data").Value("data").Object(). | ||
| 38 | + ContainsKey("count").ValueEqual("count", 1). | ||
| 39 | + ContainsKey("systemSettings").Value("systemSettings").Array() | ||
| 40 | + }) | ||
| 41 | + }) | ||
| 42 | + }) | ||
| 43 | + AfterEach(func() { | ||
| 44 | + _, err := pG.DB.Exec("DELETE FROM system_settings WHERE true") | ||
| 45 | + Expect(err).NotTo(HaveOccurred()) | ||
| 46 | + }) | ||
| 47 | +}) |
| 1 | +package system_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + "net/http/httptest" | ||
| 6 | + "testing" | ||
| 7 | + | ||
| 8 | + "github.com/beego/beego/v2/server/web" | ||
| 9 | + . "github.com/onsi/ginkgo" | ||
| 10 | + . "github.com/onsi/gomega" | ||
| 11 | + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg" | ||
| 12 | + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +func TestSystemSetting(t *testing.T) { | ||
| 16 | + RegisterFailHandler(Fail) | ||
| 17 | + RunSpecs(t, "Beego Port SystemSetting Correlations Test Case Suite") | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +var handler http.Handler | ||
| 21 | +var server *httptest.Server | ||
| 22 | + | ||
| 23 | +var _ = BeforeSuite(func() { | ||
| 24 | + handler = web.BeeApp.Handlers | ||
| 25 | + server = httptest.NewServer(handler) | ||
| 26 | +}) | ||
| 27 | + | ||
| 28 | +var _ = AfterSuite(func() { | ||
| 29 | + server.Close() | ||
| 30 | +}) |
| 1 | +package system_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + . "github.com/onsi/ginkgo" | ||
| 8 | + . "github.com/onsi/gomega" | ||
| 9 | + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +var _ = Describe("更新用户的系统设置", func() { | ||
| 13 | + var systemSettingId int64 | ||
| 14 | + BeforeEach(func() { | ||
| 15 | + _, err := pG.DB.QueryOne( | ||
| 16 | + pg.Scan(&systemSettingId), | ||
| 17 | + "INSERT INTO system_settings (company_id, control_level, description, setting_code, setting_name, system_setting_id, value, value_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING system_setting_id", | ||
| 18 | + "testCompanyId", "testControlLevel", "testDescription", "testSettingCode", "testSettingName", "testSystemSettingId", "testValue", "testValueType") | ||
| 19 | + Expect(err).NotTo(HaveOccurred()) | ||
| 20 | + }) | ||
| 21 | + Describe("提交数据更新用户的系统设置", func() { | ||
| 22 | + Context("提交正确的系统参数设置数据", func() { | ||
| 23 | + It("返回更新后的系统参数设置数据", func() { | ||
| 24 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 25 | + body := map[string]interface{}{ | ||
| 26 | + "settingCode": "string", | ||
| 27 | + "companyId": "int64", | ||
| 28 | + } | ||
| 29 | + httpExpect.PUT("/system-settings/"). | ||
| 30 | + WithJSON(body). | ||
| 31 | + Expect(). | ||
| 32 | + Status(http.StatusOK). | ||
| 33 | + JSON(). | ||
| 34 | + Object(). | ||
| 35 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 36 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 37 | + ContainsKey("data").Value("data").Object(). | ||
| 38 | + ContainsKey("systemSettingId").ValueEqual("systemSettingId", systemSettingId) | ||
| 39 | + }) | ||
| 40 | + }) | ||
| 41 | + }) | ||
| 42 | + AfterEach(func() { | ||
| 43 | + _, err := pG.DB.Exec("DELETE FROM system_settings WHERE true") | ||
| 44 | + Expect(err).NotTo(HaveOccurred()) | ||
| 45 | + }) | ||
| 46 | +}) |
-
请 注册 或 登录 后发表评论