|
@@ -121,10 +121,10 @@ func (s *TestPublicSuite) TestIsCode() {
|
|
|
}
|
|
|
|
|
|
func (s *TestPublicSuite) TestSetServiceCode() {
|
|
|
- SetAppCode(300000)
|
|
|
+ SetAppCode(3)
|
|
|
NewOK(2001, "ok")
|
|
|
err := WithCode(nil, 2001)
|
|
|
- s.Equal(302001, ParseCode(err).BusinessCode)
|
|
|
+ s.Equal(32001, ParseCode(err).BusinessCode)
|
|
|
}
|
|
|
|
|
|
func (s *TestPublicSuite) TestWithStack() {
|
|
@@ -144,24 +144,24 @@ func TestServiceCode(t *testing.T) {
|
|
|
assert.Equal(t, 10001, code.BusinessCode)
|
|
|
assert.Equal(t, http.StatusInternalServerError, code.HttpCode)
|
|
|
|
|
|
- SetAppCode(10)
|
|
|
+ SetAppCode(2)
|
|
|
NewBadRequest(ErrDb, "db error")
|
|
|
code = ParseCode(WithCode(nil, ErrDb))
|
|
|
assert.Equal(t, "db error", code.Msg)
|
|
|
- assert.Equal(t, 100002, code.BusinessCode)
|
|
|
+ assert.Equal(t, 20002, code.BusinessCode)
|
|
|
assert.Equal(t, http.StatusBadRequest, code.HttpCode)
|
|
|
|
|
|
- SetAppCode(100000)
|
|
|
+ SetAppCode(3)
|
|
|
NewInternalError(ErrParam, "param error")
|
|
|
code = ParseCode(WithCode(nil, ErrParam))
|
|
|
assert.Equal(t, "param error", code.Msg)
|
|
|
- assert.Equal(t, 100003, code.BusinessCode)
|
|
|
+ assert.Equal(t, 30003, code.BusinessCode)
|
|
|
assert.Equal(t, http.StatusInternalServerError, code.HttpCode)
|
|
|
|
|
|
- SetAppCode(1000)
|
|
|
+ SetAppCode(4)
|
|
|
NewConflict(ErrRetry, "retry error")
|
|
|
code = ParseCode(WithCode(nil, ErrRetry))
|
|
|
- assert.Equal(t, 100004, code.BusinessCode)
|
|
|
+ assert.Equal(t, 40004, code.BusinessCode)
|
|
|
assert.Equal(t, http.StatusConflict, code.HttpCode)
|
|
|
assert.Equal(t, "retry error", code.Msg)
|
|
|
}
|