aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/client/http/common_test.go
diff options
context:
space:
mode:
authorferhat elmas <elmas.ferhat@gmail.com>2016-11-15 01:18:53 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-11-15 01:18:53 +0100
commit16d86605732ba3198c0acd4317b53cf4991a7d4d (patch)
tree3306f0438235f7dfe19fd37c5393a4794abe0535 /plumbing/client/http/common_test.go
parenteb89d2dd9a36440d58aea224c055b364e49785f7 (diff)
downloadgo-git-16d86605732ba3198c0acd4317b53cf4991a7d4d.tar.gz
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
Diffstat (limited to 'plumbing/client/http/common_test.go')
-rw-r--r--plumbing/client/http/common_test.go19
1 files changed, 9 insertions, 10 deletions
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)
}