aboutsummaryrefslogtreecommitdiffstats
path: root/blame_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-10-16 11:16:14 +0200
committerGitHub <noreply@github.com>2018-10-16 11:16:14 +0200
commit236ae868ec4a62af2f7eec79d622ab0ebc94ccef (patch)
tree649d2ea793e48d82c9f447256673ab3d054ed378 /blame_test.go
parent41d6f2c31e68a9fdcbff4a3da8c40247f1293cc9 (diff)
parentc4be04433cf894cead23cd1de2be54c2886e44ad (diff)
downloadgo-git-236ae868ec4a62af2f7eec79d622ab0ebc94ccef.tar.gz
Merge pull request #986 from mcuadros/fix-blame
blame: fix edge case with missing \n in content length causing mismatched length error
Diffstat (limited to 'blame_test.go')
-rw-r--r--blame_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/blame_test.go b/blame_test.go
index 92911b1..e0ac129 100644
--- a/blame_test.go
+++ b/blame_test.go
@@ -2,6 +2,7 @@ package git
import (
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git-fixtures.v3"
@@ -13,6 +14,31 @@ type BlameSuite struct {
var _ = Suite(&BlameSuite{})
+func (s *BlameSuite) TestNewLines(c *C) {
+ h := plumbing.NewHash("ce9f123d790717599aaeb76bc62510de437761be")
+ lines, err := newLines([]string{"foo"}, []*object.Commit{{
+ Hash: h,
+ Message: "foo",
+ }})
+
+ c.Assert(err, IsNil)
+ c.Assert(lines, HasLen, 1)
+ c.Assert(lines[0].Text, Equals, "foo")
+ c.Assert(lines[0].Hash, Equals, h)
+}
+
+func (s *BlameSuite) TestNewLinesWithNewLine(c *C) {
+ lines, err := newLines([]string{"foo"}, []*object.Commit{
+ {Message: "foo"},
+ {Message: "bar"},
+ })
+
+ c.Assert(err, IsNil)
+ c.Assert(lines, HasLen, 2)
+ c.Assert(lines[0].Text, Equals, "foo")
+ c.Assert(lines[1].Text, Equals, "\n")
+}
+
type blameTest struct {
repo string
rev string