修复go的验证库把int的0当作无值的情况
This commit is contained in:
@@ -225,7 +225,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
||||
|
||||
t.Run("成功禁用角色", func(t *testing.T) {
|
||||
reqBody := dto.UpdateRoleStatusRequest{
|
||||
Status: constants.StatusDisabled,
|
||||
Status: intPtr(constants.StatusDisabled),
|
||||
}
|
||||
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -245,7 +245,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
||||
|
||||
t.Run("成功启用角色", func(t *testing.T) {
|
||||
reqBody := dto.UpdateRoleStatusRequest{
|
||||
Status: constants.StatusEnabled,
|
||||
Status: intPtr(constants.StatusEnabled),
|
||||
}
|
||||
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -265,7 +265,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
||||
|
||||
t.Run("角色不存在返回错误", func(t *testing.T) {
|
||||
reqBody := dto.UpdateRoleStatusRequest{
|
||||
Status: constants.StatusEnabled,
|
||||
Status: intPtr(constants.StatusEnabled),
|
||||
}
|
||||
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -278,3 +278,8 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
||||
assert.Equal(t, errors.CodeRoleNotFound, result.Code)
|
||||
})
|
||||
}
|
||||
|
||||
// intPtr 返回 int 的指针
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user