aboutsummaryrefslogtreecommitdiffstats
path: root/config/refspec_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-08 14:24:12 +0100
committerGitHub <noreply@github.com>2016-12-08 14:24:12 +0100
commit3962b8d4dbb2d2d61e9282d73f8d3d0f2a222461 (patch)
tree30e660ad822abaf77c360a52f56e7e81ba250ad3 /config/refspec_test.go
parenta91727b6d5e6d8db17e960de6255bc848c78a076 (diff)
downloadgo-git-3962b8d4dbb2d2d61e9282d73f8d3d0f2a222461.tar.gz
config: support delete refspecs (IsDelete). (#166)
Diffstat (limited to 'config/refspec_test.go')
-rw-r--r--config/refspec_test.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/config/refspec_test.go b/config/refspec_test.go
index f0d1a0e..e0f052a 100644
--- a/config/refspec_test.go
+++ b/config/refspec_test.go
@@ -23,6 +23,15 @@ func (s *RefSpecSuite) TestRefSpecIsValid(c *C) {
spec = RefSpec("refs/heads/master:refs/remotes/origin/master")
c.Assert(spec.IsValid(), Equals, true)
+ spec = RefSpec(":refs/heads/master")
+ c.Assert(spec.IsValid(), Equals, true)
+
+ spec = RefSpec(":refs/heads/*")
+ c.Assert(spec.IsValid(), Equals, false)
+
+ spec = RefSpec(":*")
+ c.Assert(spec.IsValid(), Equals, false)
+
spec = RefSpec("refs/heads/*")
c.Assert(spec.IsValid(), Equals, false)
}
@@ -35,18 +44,36 @@ func (s *RefSpecSuite) TestRefSpecIsForceUpdate(c *C) {
c.Assert(spec.IsForceUpdate(), Equals, false)
}
+func (s *RefSpecSuite) TestRefSpecIsDelete(c *C) {
+ spec := RefSpec(":refs/heads/master")
+ c.Assert(spec.IsDelete(), Equals, true)
+
+ spec = RefSpec("+refs/heads/*:refs/remotes/origin/*")
+ c.Assert(spec.IsDelete(), Equals, false)
+
+ spec = RefSpec("refs/heads/*:refs/remotes/origin/*")
+ c.Assert(spec.IsDelete(), Equals, false)
+}
+
func (s *RefSpecSuite) TestRefSpecSrc(c *C) {
spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
c.Assert(spec.Src(), Equals, "refs/heads/*")
+
+ spec = RefSpec(":refs/heads/master")
+ c.Assert(spec.Src(), Equals, "")
}
func (s *RefSpecSuite) TestRefSpecMatch(c *C) {
spec := RefSpec("refs/heads/master:refs/remotes/origin/master")
c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/foo")), Equals, false)
c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/master")), Equals, true)
+
+ spec = RefSpec(":refs/heads/master")
+ c.Assert(spec.Match(plumbing.ReferenceName("")), Equals, true)
+ c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/master")), Equals, false)
}
-func (s *RefSpecSuite) TestRefSpecMatchBlob(c *C) {
+func (s *RefSpecSuite) TestRefSpecMatchGlob(c *C) {
spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
c.Assert(spec.Match(plumbing.ReferenceName("refs/tag/foo")), Equals, false)
c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/foo")), Equals, true)