aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/gitattributes/matcher_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-04-24 14:38:25 +0200
committerGitHub <noreply@github.com>2019-04-24 14:38:25 +0200
commitbbca4e0ccc8fee164e6da28edebbd76d69cdfd9b (patch)
treea7a3f9fb8d84ea78b002be45c7380080fe21025d /plumbing/format/gitattributes/matcher_test.go
parent4a6229296f5d8991d46e581d331e4e889a5a87ec (diff)
parent86bdbfbf45a0c13aca146955a3325207ebd66c75 (diff)
downloadgo-git-bbca4e0ccc8fee164e6da28edebbd76d69cdfd9b.tar.gz
Merge pull request #1130 from saracen/gitattributes
plumbing: format/gitattributes support
Diffstat (limited to 'plumbing/format/gitattributes/matcher_test.go')
-rw-r--r--plumbing/format/gitattributes/matcher_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/plumbing/format/gitattributes/matcher_test.go b/plumbing/format/gitattributes/matcher_test.go
new file mode 100644
index 0000000..edb71a1
--- /dev/null
+++ b/plumbing/format/gitattributes/matcher_test.go
@@ -0,0 +1,29 @@
+package gitattributes
+
+import (
+ "strings"
+
+ . "gopkg.in/check.v1"
+)
+
+func (s *MatcherSuite) TestMatcher_Match(c *C) {
+ lines := []string{
+ "[attr]binary -diff -merge -text",
+ "**/middle/v[uo]l?ano binary text eol=crlf",
+ "volcano -eol",
+ "foobar diff merge text eol=lf foo=bar",
+ }
+
+ ma, err := ReadAttributes(strings.NewReader(strings.Join(lines, "\n")), nil, true)
+ c.Assert(err, IsNil)
+
+ m := NewMatcher(ma)
+ results, matched := m.Match([]string{"head", "middle", "vulkano"}, nil)
+
+ c.Assert(matched, Equals, true)
+ c.Assert(results["binary"].IsSet(), Equals, true)
+ c.Assert(results["diff"].IsUnset(), Equals, true)
+ c.Assert(results["merge"].IsUnset(), Equals, true)
+ c.Assert(results["text"].IsSet(), Equals, true)
+ c.Assert(results["eol"].Value(), Equals, "crlf")
+}