aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/http/common_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/transport/http/common_test.go')
-rw-r--r--plumbing/transport/http/common_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/plumbing/transport/http/common_test.go b/plumbing/transport/http/common_test.go
index 1517228..6bd018b 100644
--- a/plumbing/transport/http/common_test.go
+++ b/plumbing/transport/http/common_test.go
@@ -3,6 +3,7 @@ package http
import (
"crypto/tls"
"fmt"
+ "io"
"log"
"net"
"net/http"
@@ -14,6 +15,7 @@ import (
"strings"
"testing"
+ "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/transport"
fixtures "github.com/go-git/go-git-fixtures/v4"
@@ -90,6 +92,23 @@ func (s *ClientSuite) TestNewHTTPError40x(c *C) {
"unexpected client error.*")
}
+func (s *ClientSuite) TestNewUnexpectedError(c *C) {
+ res := &http.Response{
+ StatusCode: 500,
+ Body: io.NopCloser(strings.NewReader("Unexpected error")),
+ }
+
+ err := NewErr(res)
+ c.Assert(err, NotNil)
+ c.Assert(err, FitsTypeOf, &plumbing.UnexpectedError{})
+
+ unexpectedError, _ := err.(*plumbing.UnexpectedError)
+ c.Assert(unexpectedError.Err, FitsTypeOf, &Err{})
+
+ httpError, _ := unexpectedError.Err.(*Err)
+ c.Assert(httpError.Reason, Equals, "Unexpected error")
+}
+
func (s *ClientSuite) Test_newSession(c *C) {
cl := NewClientWithOptions(nil, &ClientOptions{
CacheMaxEntries: 2,