From 16d86605732ba3198c0acd4317b53cf4991a7d4d Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Tue, 15 Nov 2016 01:18:53 +0100 Subject: Add configurable http client factory (fixes #120) (#121) * new http client factory ready to install/override default http(s) * mv GitUploadPackServiceFactory to clients.common pkg * rename http.HTTPError to http.Err * rename http.HTTPAuthMethod to http.AuthMethod * add doc and examples/ usage * general improvements: - update install link in readme to v4 (example are already pointing v4) - fix indentation in package doc (styling for godoc.org) - use http.Status constants instead of integers - close leaked response body - rm named returns which stutter in doc - fix one format string - rm unnecessary if checks - documentation fixes --- plumbing/client/http/common_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'plumbing/client/http/common_test.go') diff --git a/plumbing/client/http/common_test.go b/plumbing/client/http/common_test.go index 287897d..7503d84 100644 --- a/plumbing/client/http/common_test.go +++ b/plumbing/client/http/common_test.go @@ -20,23 +20,22 @@ func (s *SuiteCommon) TestNewBasicAuth(c *C) { c.Assert(a.String(), Equals, "http-basic-auth - foo:*******") } -func (s *SuiteCommon) TestNewHTTPError200(c *C) { - res := &http.Response{StatusCode: 200} - res.StatusCode = 200 - err := NewHTTPError(res) +func (s *SuiteCommon) TestNewErrOK(c *C) { + res := &http.Response{StatusCode: http.StatusOK} + err := NewErr(res) c.Assert(err, IsNil) } -func (s *SuiteCommon) TestNewHTTPError401(c *C) { - s.testNewHTTPError(c, 401, "authorization required") +func (s *SuiteCommon) TestNewErrUnauthorized(c *C) { + s.testNewHTTPError(c, http.StatusUnauthorized, "authorization required") } -func (s *SuiteCommon) TestNewHTTPError404(c *C) { - s.testNewHTTPError(c, 404, "repository not found") +func (s *SuiteCommon) TestNewErrNotFound(c *C) { + s.testNewHTTPError(c, http.StatusNotFound, "repository not found") } func (s *SuiteCommon) TestNewHTTPError40x(c *C) { - s.testNewHTTPError(c, 402, "unexpected client error.*") + s.testNewHTTPError(c, http.StatusPaymentRequired, "unexpected client error.*") } func (s *SuiteCommon) testNewHTTPError(c *C, code int, msg string) { @@ -46,7 +45,7 @@ func (s *SuiteCommon) testNewHTTPError(c *C, code int, msg string) { Request: req, } - err := NewHTTPError(res) + err := NewErr(res) c.Assert(err, NotNil) c.Assert(err, ErrorMatches, msg) } -- cgit