center_test.go 699 B

1234567891011121314151617181920212223242526272829303132
  1. package fserr
  2. import (
  3. "github.com/stretchr/testify/suite"
  4. "net/http"
  5. "testing"
  6. )
  7. type TestCenterSuite struct {
  8. suite.Suite
  9. expectedBusinessCode int
  10. }
  11. func (s *TestCenterSuite) SetupTest() {
  12. s.expectedBusinessCode = 1001
  13. register(NewOK(s.expectedBusinessCode, "ok"))
  14. }
  15. func (s *TestCenterSuite) TestGetCenterErrCode() {
  16. s.Equal(s.expectedBusinessCode, getCode(s.expectedBusinessCode).BusinessCode)
  17. }
  18. func (s *TestCenterSuite) TestDefaultErrCode() {
  19. notExistErrCode := getCode(2001)
  20. s.Equal("", notExistErrCode.Message)
  21. s.Equal(http.StatusOK, defaultErrCode.HttpCode)
  22. s.Equal(2001, notExistErrCode.BusinessCode)
  23. }
  24. func TestCenter(t *testing.T) {
  25. suite.Run(t, &TestCenterSuite{})
  26. }