aboutsummaryrefslogtreecommitdiffstats
path: root/config/refspec_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-19 17:42:13 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-19 17:42:13 +0200
commit1d56b98d9b02e20f7feea542c75746eab34fad63 (patch)
tree006e8c3ac5e40353032109a5259bb28c37751996 /config/refspec_test.go
parentb1d116c59f7656dc8d5ff7294ba8f8a82c51bfd1 (diff)
downloadgo-git-1d56b98d9b02e20f7feea542c75746eab34fad63.tar.gz
Remote.Fetch base on RefSpec, improvement of the responsabilities separation
Diffstat (limited to 'config/refspec_test.go')
-rw-r--r--config/refspec_test.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/config/refspec_test.go b/config/refspec_test.go
new file mode 100644
index 0000000..b0bb8f5
--- /dev/null
+++ b/config/refspec_test.go
@@ -0,0 +1,69 @@
+package config
+
+import (
+ "testing"
+
+ . "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git.v4/core"
+)
+
+type RefSpecSuite struct{}
+
+var _ = Suite(&RefSpecSuite{})
+
+func Test(t *testing.T) { TestingT(t) }
+
+func (s *RefSpecSuite) TestRefSpecIsValid(c *C) {
+ spec := RefSpec("+refs/heads/*:refs/remotes/origin/*")
+ c.Assert(spec.IsValid(), Equals, true)
+
+ spec = RefSpec("refs/heads/*:refs/remotes/origin/")
+ c.Assert(spec.IsValid(), Equals, false)
+
+ spec = RefSpec("refs/heads/master:refs/remotes/origin/master")
+ c.Assert(spec.IsValid(), Equals, true)
+
+ spec = RefSpec("refs/heads/*")
+ c.Assert(spec.IsValid(), Equals, false)
+}
+
+func (s *RefSpecSuite) TestRefSpecIsForceUpdate(c *C) {
+ spec := RefSpec("+refs/heads/*:refs/remotes/origin/*")
+ c.Assert(spec.IsForceUpdate(), Equals, true)
+
+ spec = RefSpec("refs/heads/*:refs/remotes/origin/*")
+ c.Assert(spec.IsForceUpdate(), Equals, false)
+}
+
+func (s *RefSpecSuite) TestRefSpecSrc(c *C) {
+ spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
+ c.Assert(spec.Src(), Equals, "refs/heads/*")
+}
+
+func (s *RefSpecSuite) TestRefSpecMatch(c *C) {
+ spec := RefSpec("refs/heads/master:refs/remotes/origin/master")
+ c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, false)
+ c.Assert(spec.Match(core.ReferenceName("refs/heads/master")), Equals, true)
+}
+
+func (s *RefSpecSuite) TestRefSpecMatchBlob(c *C) {
+ spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
+ c.Assert(spec.Match(core.ReferenceName("refs/tag/foo")), Equals, false)
+ c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, true)
+}
+
+func (s *RefSpecSuite) TestRefSpecDst(c *C) {
+ spec := RefSpec("refs/heads/master:refs/remotes/origin/master")
+ c.Assert(
+ spec.Dst(core.ReferenceName("refs/heads/master")).String(), Equals,
+ "refs/remotes/origin/master",
+ )
+}
+
+func (s *RefSpecSuite) TestRefSpecDstBlob(c *C) {
+ spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
+ c.Assert(
+ spec.Dst(core.ReferenceName("refs/heads/foo")).String(), Equals,
+ "refs/remotes/origin/foo",
+ )
+}