aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/pktline/scanner_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-11-30 17:23:56 +0100
committerGitHub <noreply@github.com>2016-11-30 17:23:56 +0100
commitb0d756c93d8deb5d4c6a129c5bd3163dddd10132 (patch)
tree4aeeae8ec9af66067ff2b83d03653156d53c640d /plumbing/format/pktline/scanner_test.go
parent606370479fbf0e315ccffcea8d86126c4a0c9db2 (diff)
downloadgo-git-b0d756c93d8deb5d4c6a129c5bd3163dddd10132.tar.gz
format/pktline: fix readPayloadLen err handling (#148)
Diffstat (limited to 'plumbing/format/pktline/scanner_test.go')
-rw-r--r--plumbing/format/pktline/scanner_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/plumbing/format/pktline/scanner_test.go b/plumbing/format/pktline/scanner_test.go
index 9f440a4..b8a78ec 100644
--- a/plumbing/format/pktline/scanner_test.go
+++ b/plumbing/format/pktline/scanner_test.go
@@ -2,6 +2,7 @@ package pktline_test
import (
"bytes"
+ "errors"
"fmt"
"io"
"strings"
@@ -145,6 +146,16 @@ func (s *SuiteScanner) TestEOF(c *C) {
c.Assert(sc.Err(), IsNil)
}
+type mockReader struct{}
+
+func (r *mockReader) Read([]byte) (int, error) { return 0, errors.New("foo") }
+
+func (s *SuiteScanner) TestInternalReadError(c *C) {
+ sc := pktline.NewScanner(&mockReader{})
+ c.Assert(sc.Scan(), Equals, false)
+ c.Assert(sc.Err(), ErrorMatches, "foo")
+}
+
// A section are several non flush-pkt lines followed by a flush-pkt, which
// how the git protocol sends long messages.
func (s *SuiteScanner) TestReadSomeSections(c *C) {