errors_test.go 380 B

1234567891011121314151617181920212223
  1. package errors_test
  2. import (
  3. "testing"
  4. "github.com/v2ray/v2ray-core/common/errors"
  5. "github.com/v2ray/v2ray-core/testing/unit"
  6. )
  7. type MockError struct {
  8. errors.ErrorCode
  9. }
  10. func (err MockError) Error() string {
  11. return "This is a fake error."
  12. }
  13. func TestHasCode(t *testing.T) {
  14. assert := unit.Assert(t)
  15. err := MockError{ErrorCode: 101}
  16. assert.Error(err).HasCode(101)
  17. }