Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1382 from hs0210/work
Browse files Browse the repository at this point in the history
test: add unit test case for func NewHTTPError
  • Loading branch information
zhouhaibing089 authored Jun 9, 2020
2 parents d92dfcb + ea73b4f commit f372031
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/errortypes/errortypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,19 @@ func (suite *ErrorTestSuite) TestIsRangeNotSatisfiable(c *check.C) {
c.Assert(IsRangeNotSatisfiable(*err1), check.Equals, true)
c.Assert(IsRangeNotSatisfiable(*err2), check.Equals, false)
}

func (suite *ErrorTestSuite) TestNewHTTPError(c *check.C) {
err := NewHTTPError(1, "test")
c.Assert(err.Code, check.Equals, 1)
c.Assert(err.Msg, check.Equals, "test")
}

func (suite *ErrorTestSuite) TestHTTPError(c *check.C) {
err := NewHTTPError(1, "test")
c.Assert(err.Error(), check.Equals, "{\"Code\":1,\"Msg\":\"test\"}")
}

func (suite *ErrorTestSuite) TestHTTPCode(c *check.C) {
err := NewHTTPError(1, "test")
c.Assert(err.HTTPCode(), check.Equals, 1)
}

0 comments on commit f372031

Please sign in to comment.