From ea73b4f876f721507f9222a290e32b0ec9b4e77c Mon Sep 17 00:00:00 2001 From: Hu Shuai Date: Mon, 8 Jun 2020 10:48:17 +0800 Subject: [PATCH] test: add some unit test cases for pkg/errortypes/errortypes.go Signed-off-by: Hu Shuai --- pkg/errortypes/errortypes_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/errortypes/errortypes_test.go b/pkg/errortypes/errortypes_test.go index c934871ce..864ed6822 100644 --- a/pkg/errortypes/errortypes_test.go +++ b/pkg/errortypes/errortypes_test.go @@ -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) +}