作者 yangfu

add users test case

... ... @@ -14,7 +14,7 @@ type ConvertUserStatusCommand struct {
}
func (convertUserStatusCommand *ConvertUserStatusCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (convertUserStatusCommand *ConvertUserStatusCommand) ValidateCommand() error {
... ...
... ... @@ -29,7 +29,7 @@ type CreateUserCommand struct {
}
func (createUserCommand *CreateUserCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createUserCommand *CreateUserCommand) ValidateCommand() error {
... ...
... ... @@ -12,7 +12,7 @@ type RemoveUserCommand struct {
}
func (removeUserCommand *RemoveUserCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeUserCommand *RemoveUserCommand) ValidateCommand() error {
... ...
... ... @@ -14,7 +14,7 @@ type SetPermissionCommand struct {
}
func (setPermissionCommand *SetPermissionCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (setPermissionCommand *SetPermissionCommand) ValidateCommand() error {
... ...
... ... @@ -2,10 +2,8 @@ package command
import (
"fmt"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain"
"time"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/domain"
)
type UpdateUserCommand struct {
... ... @@ -16,39 +14,9 @@ type UpdateUserCommand struct {
// 管理员类型 1.超级管理员 10:企业管理员 100:普通用户
AdminType int `json:"adminType,omitempty"`
// 状态 1正常 2禁用
Status int64 `json:"status" valid:"Required"`
Status int64 `json:"status,omitempty"`
// 是否是公司负责人
IsPrincipal bool `json:"isPrincipal" valid:"Required"`
// 统一用户id
Uid int64 `json:"uid" valid:"Required"`
// 用户账号
UserAccount string `json:"userAccount" valid:"Required"`
// 用户头像URL
UserAvatarUrl string `json:"userAvatarUrl" valid:"Required"`
// 用户名称
UserName string `json:"userName" valid:"Required"`
// 邮件地址
Email string `json:"email" valid:"Required"`
// 性别
Gender int `json:"gender" valid:"Required"`
// 入职时间
EntryTime time.Time `json:"entryTime" valid:"Required"`
// 分机
Extension string `json:"extension" valid:"Required"`
// 工作地
Workplace string `json:"workplace" valid:"Required"`
// 私人电话
PrivateNumber string `json:"privateNumber" valid:"Required"`
// 工号
JobNumber string `json:"jobNumber" valid:"Required"`
// 合伙人账号
PartnerAccount string `json:"partnerAccount" valid:"Required"`
// 合伙人姓名
PartnerName string `json:"partnerName" valid:"Required"`
// 区域名称 eg:华南地区
RegionName string `json:"regionName,omitempty"`
// 合伙时间
CooperateTime time.Time `json:"cooperateTime" valid:"Required"`
UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
// 业务员
Salesmans []*domain.Salesman `json:"salesmans,omitempty"`
// 合伙人类型
... ... @@ -58,7 +26,7 @@ type UpdateUserCommand struct {
}
func (updateUserCommand *UpdateUserCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateUserCommand *UpdateUserCommand) ValidateCommand() error {
... ...
... ... @@ -12,7 +12,7 @@ type GetUserQuery struct {
}
func (getUserQuery *GetUserQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getUserQuery *GetUserQuery) ValidateQuery() error {
... ...
... ... @@ -8,13 +8,13 @@ import (
type ListUserQuery struct {
// 查询偏离量
Offset int `json:"offset" valid:"Required"`
Offset int `json:"offset"`
// 查询限制
Limit int `json:"limit" valid:"Required"`
}
func (listUserQuery *ListUserQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listUserQuery *ListUserQuery) ValidateQuery() error {
... ...
... ... @@ -30,6 +30,29 @@ func (userService *UserService) ConvertUserStatus(convertUserStatusCommand *comm
defer func() {
transactionContext.RollbackTransaction()
}()
var userRepository domain.UserRepository
if value, err := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userRepository = value
}
user, err := userRepository.FindOne(map[string]interface{}{"userId": convertUserStatusCommand.UserId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if user == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(convertUserStatusCommand.UserId)))
}
if err := user.CovertUserStatus(convertUserStatusCommand.Status); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if _, err := userRepository.Save(user); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -60,8 +83,8 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser
PartnerInfo: createUserCommand.PartnerInfo,
AccessPartners: createUserCommand.AccessPartners,
}
var addUserService service.AddUserService
if value, err := factory.CreateAddUserService(map[string]interface{}{
var addUserService service.UserCreateService
if value, err := factory.CreateUserCreateService(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -69,7 +92,7 @@ func (userService *UserService) CreateUser(createUserCommand *command.CreateUser
addUserService = value
}
if user, err := addUserService.AddUser(newUser); err != nil {
if user, err := addUserService.CreateUser(0, newUser); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -207,6 +230,29 @@ func (userService *UserService) SetPermission(setPermissionCommand *command.SetP
defer func() {
transactionContext.RollbackTransaction()
}()
var userRepository domain.UserRepository
if value, err := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userRepository = value
}
user, err := userRepository.FindOne(map[string]interface{}{"userId": setPermissionCommand.UserId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if user == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(setPermissionCommand.UserId)))
}
if err := user.SetPermission(setPermissionCommand.Permissons); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if _, err := userRepository.Save(user); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ...
... ... @@ -68,6 +68,19 @@ func (user *User) Identify() interface{} {
return user.UserId
}
func (user *User) SetPermission(permissions []int) error {
user.Permissions = permissions
return nil
}
func (user *User) CovertUserStatus(status int64) error {
if !(status == StatusEnable || status == StatusDisable) {
return fmt.Errorf("status options value (%v,%v) , invalid %v", StatusEnable, StatusDisable, status)
}
user.Status = status
return nil
}
func (user *User) Update(data map[string]interface{}) error {
if userType, ok := data["userType"]; ok {
user.UserType = userType.(int)
... ... @@ -75,44 +88,8 @@ func (user *User) Update(data map[string]interface{}) error {
if permissions, ok := data["permissions"]; ok {
user.Permissions = permissions.([]int)
}
if companyId, ok := data["companyId"]; ok {
user.CompanyId = companyId.(int64)
}
if isPrincipal, ok := data["isPrincipal"]; ok {
user.UserInfo.IsPrincipal = isPrincipal.(bool)
}
if uid, ok := data["uid"]; ok {
user.UserInfo.Uid = uid.(int64)
}
if userAccount, ok := data["userAccount"]; ok {
user.UserInfo.UserAccount = userAccount.(string)
}
if userAvatarUrl, ok := data["userAvatarUrl"]; ok {
user.UserInfo.UserAvatarUrl = userAvatarUrl.(string)
}
if userName, ok := data["userName"]; ok {
user.UserInfo.UserName = userName.(string)
}
if email, ok := data["email"]; ok {
user.UserInfo.Email = email.(string)
}
if gender, ok := data["gender"]; ok {
user.UserInfo.Gender = gender.(int)
}
if entryTime, ok := data["entryTime"]; ok {
user.UserInfo.EntryTime = entryTime.(time.Time)
}
if extension, ok := data["extension"]; ok {
user.UserInfo.Extension = extension.(string)
}
if workplace, ok := data["workplace"]; ok {
user.UserInfo.Workplace = workplace.(string)
}
if privateNumber, ok := data["privateNumber"]; ok {
user.UserInfo.PrivateNumber = privateNumber.(string)
}
if jobNumber, ok := data["jobNumber"]; ok {
user.UserInfo.JobNumber = jobNumber.(string)
if userInfo, ok := data["userInfo"]; ok {
user.UserInfo = userInfo.(*UserInfo)
}
if partnerAccount, ok := data["partnerAccount"]; ok {
user.PartnerInfo.PartnerAccount = partnerAccount.(string)
... ... @@ -126,6 +103,7 @@ func (user *User) Update(data map[string]interface{}) error {
if status, ok := data["status"]; ok {
user.PartnerInfo.Status = status.(int64)
}
user.UpdateAt = time.Now()
return nil
}
... ...
... ... @@ -43,7 +43,7 @@ func (repository *UserRepository) Save(user *domain.User) (*domain.User, error)
insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
returningFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "user_id")
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "user_id", "delete_at", "create_at")
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
tx := repository.transactionContext.PgTx
if user.Identify() == nil {
... ... @@ -104,7 +104,6 @@ func (repository *UserRepository) Save(user *domain.User) (*domain.User, error)
&user.DeleteAt,
),
fmt.Sprintf("UPDATE users SET %s WHERE user_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
user.UserId,
user.UserType,
pg.Array(user.Permissions),
user.CompanyId,
... ... @@ -114,9 +113,7 @@ func (repository *UserRepository) Save(user *domain.User) (*domain.User, error)
user.Status,
user.AdminType,
pg.Array(user.AccessPartners),
user.CreateAt,
user.UpdateAt,
user.DeleteAt,
user.Identify(),
); err != nil {
return user, err
... ...
... ... @@ -11,13 +11,12 @@ import (
)
var _ = Describe("用户状态转换(禁用、启用)", func() {
return
var userId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&userId),
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type, access_partners, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
"testUserId", "testUserType", "testPermissions", "testCompanyId", "testUserInfo", "testPartnerInfo", "testStatus", "testAdminType", "testAccessPartners", "testCreateAt", "testUpdateAt", "testDeleteAt")
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
1, 1, pg.Array([]int{}), 1, `{}`, `{}`, 1, 1)
Expect(err).NotTo(HaveOccurred())
})
Describe("用户状态转换(禁用、启用)", func() {
... ... @@ -25,23 +24,23 @@ var _ = Describe("用户状态转换(禁用、启用)", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"status": "int64",
"userId": 1,
"status": 2,
}
httpExpect.POST("/users/convertUserStatus").
httpExpect.POST("/users/convert-user-status").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
ContainsKey("msg").ValueEqual("msg", "ok")
//ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
//_, err := pG.DB.Exec("DELETE FROM users WHERE true")
//Expect(err).NotTo(HaveOccurred())
_, err := pG.DB.Exec("DELETE FROM users WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package user
import (
pG "gitlab.fjmaimaimai.com/mmm-go-pp/partner01/pkg/infrastructure/pg"
"net/http"
"github.com/gavv/httpexpect"
... ... @@ -14,24 +15,23 @@ var _ = Describe("创建", func() {
It("返回用户实体数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userType": 1,
"adminType": 1,
"status": 1,
"isPrincipal": false,
"uid": 5678664411598702,
"userAccount": "13800000000",
"userAvatarUrl": "www.baidu.com",
"userName": "彭于晏",
"email": "gfghf@qq.com",
"gender": 1,
"extension": "1",
"workplace": "2",
"privateNumber": "3",
"jobNumber": "4",
"partnerAccount": "5",
"partnerName": "6",
"regionName": "7",
"salesmans": "[1,2]",
"userType": 1,
"adminType": 1,
"status": 1,
"userAccount": "13800000000",
"userInfo": map[string]interface{}{
"isPrincipal": false,
"uid": 5678664411598702,
"userAccount": "13800000000",
"userAvatarUrl": "www.baidu.com",
"userName": "彭于晏",
"email": "gfghf@qq.com",
"gender": 1,
"extension": "1",
"workplace": "2",
"privateNumber": "3",
"jobNumber": "4",
},
"partnerCategorys": "[]",
"accessPartners": "[]",
}
... ... @@ -49,7 +49,8 @@ var _ = Describe("创建", func() {
})
})
AfterEach(func() {
//_, err := pG.DB.Exec("DELETE FROM users WHERE true")
//Expect(err).NotTo(HaveOccurred())
_, err := pG.DB.Exec("DELETE FROM users WHERE true")
_, err = pG.DB.Exec("DELETE FROM user_auth WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -11,20 +11,19 @@ import (
)
var _ = Describe("返回", func() {
return
var userId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&userId),
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type, access_partners, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
"testUserId", "testUserType", "testPermissions", "testCompanyId", "testUserInfo", "testPartnerInfo", "testStatus", "testAdminType", "testAccessPartners", "testCreateAt", "testUpdateAt", "testDeleteAt")
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
1, 1, pg.Array([]int{}), 1, `{}`, `{}`, 1, 1)
Expect(err).NotTo(HaveOccurred())
})
Describe("根据userId参数返回用户实体", func() {
Context("传入有效的userId", func() {
It("返回用户实体数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/users/{userId}").
httpExpect.GET("/users/1").
Expect().
Status(http.StatusOK).
JSON().
... ... @@ -36,7 +35,7 @@ var _ = Describe("返回", func() {
})
})
AfterEach(func() {
//_, err := pG.DB.Exec("DELETE FROM users WHERE true")
//Expect(err).NotTo(HaveOccurred())
_, err := pG.DB.Exec("DELETE FROM users WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -11,13 +11,12 @@ import (
)
var _ = Describe("返回列表", func() {
return
var userId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&userId),
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type, access_partners, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
"testUserId", "testUserType", "testPermissions", "testCompanyId", "testUserInfo", "testPartnerInfo", "testStatus", "testAdminType", "testAccessPartners", "testCreateAt", "testUpdateAt", "testDeleteAt")
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
1, 1, pg.Array([]int{}), 1, `{}`, `{}`, 1, 1)
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数返回用户实体列表", func() {
... ... @@ -25,8 +24,8 @@ var _ = Describe("返回列表", func() {
It("返回用户实体数据列表", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/users/").
WithQuery("offset", "int").
WithQuery("limit", "int").
WithQuery("offset", 0).
WithQuery("limit", 10).
Expect().
Status(http.StatusOK).
JSON().
... ... @@ -40,7 +39,7 @@ var _ = Describe("返回列表", func() {
})
})
AfterEach(func() {
//_, err := pG.DB.Exec("DELETE FROM users WHERE true")
//Expect(err).NotTo(HaveOccurred())
_, err := pG.DB.Exec("DELETE FROM users WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -11,20 +11,19 @@ import (
)
var _ = Describe("移除", func() {
return
var userId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&userId),
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type, access_partners, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
"testUserId", "testUserType", "testPermissions", "testCompanyId", "testUserInfo", "testPartnerInfo", "testStatus", "testAdminType", "testAccessPartners", "testCreateAt", "testUpdateAt", "testDeleteAt")
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
1, 1, pg.Array([]int{}), 1, `{}`, `{}`, 1, 1)
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数移除", func() {
Context("传入有效的userId", func() {
It("返回被移除用户实体的数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.DELETE("/users/{userId}").
httpExpect.DELETE("/users/1").
Expect().
Status(http.StatusOK).
JSON().
... ... @@ -36,7 +35,7 @@ var _ = Describe("移除", func() {
})
})
AfterEach(func() {
//_, err := pG.DB.Exec("DELETE FROM users WHERE true")
//Expect(err).NotTo(HaveOccurred())
_, err := pG.DB.Exec("DELETE FROM users WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
... ... @@ -16,8 +16,8 @@ var _ = Describe("设置权限", func() {
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&userId),
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type, access_partners, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
"testUserId", "testUserType", "testPermissions", "testCompanyId", "testUserInfo", "testPartnerInfo", "testStatus", "testAdminType", "testAccessPartners", "testCreateAt", "testUpdateAt", "testDeleteAt")
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
1, 1, pg.Array([]int{}), 1, `{}`, `{}`, 1, 1)
Expect(err).NotTo(HaveOccurred())
})
Describe("设置权限", func() {
... ... @@ -25,8 +25,8 @@ var _ = Describe("设置权限", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userId": "int64",
"permissons": "array",
"userId": 1,
"permissons": []int{1, 2, 3},
}
httpExpect.POST("/users/setPermission").
WithJSON(body).
... ...
... ... @@ -11,13 +11,12 @@ import (
)
var _ = Describe("更新", func() {
return
var userId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&userId),
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type, access_partners, create_at, update_at, delete_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
"testUserId", "testUserType", "testPermissions", "testCompanyId", "testUserInfo", "testPartnerInfo", "testStatus", "testAdminType", "testAccessPartners", "testCreateAt", "testUpdateAt", "testDeleteAt")
"INSERT INTO users (user_id, user_type, permissions, company_id, user_info, partner_info, status, admin_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
1, 1, pg.Array([]int{}), 1, `{}`, `{}`, 1, 1)
Expect(err).NotTo(HaveOccurred())
})
Describe("提交数据更新", func() {
... ... @@ -25,30 +24,21 @@ var _ = Describe("更新", func() {
It("返回更新后的用户实体数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"userType": "int",
"adminType": "int",
"status": "int64",
"isPrincipal": "boolean",
"uid": "int64",
"userAccount": "string",
"userAvatarUrl": "string",
"userName": "string",
"email": "string",
"gender": "int",
"entryTime": "datetime",
"extension": "string",
"workplace": "string",
"privateNumber": "string",
"jobNumber": "string",
"partnerAccount": "string",
"partnerName": "string",
"regionName": "string",
"cooperateTime": "datetime",
"salesmans": "array",
"partnerCategorys": "array",
"accessPartners": "array",
"userInfo": map[string]interface{}{
"isPrincipal": false,
"uid": 5678664411598702,
"userAccount": "13800000000",
"userAvatarUrl": "www.baidu.com",
"userName": "彭于晏01",
"email": "gfghf@qq.com",
"gender": 1,
"extension": "1",
"workplace": "2",
"privateNumber": "3",
"jobNumber": "4",
},
}
httpExpect.PUT("/users/{userId}").
httpExpect.PUT("/users/1").
WithJSON(body).
Expect().
Status(http.StatusOK).
... ... @@ -62,7 +52,7 @@ var _ = Describe("更新", func() {
})
})
AfterEach(func() {
//_, err := pG.DB.Exec("DELETE FROM users WHERE true")
//Expect(err).NotTo(HaveOccurred())
_, err := pG.DB.Exec("DELETE FROM users WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...