diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-18 01:48:25 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-18 01:48:25 +0200 |
commit | 0ed8e180c604f8ff6d68fcaad081978a407e4653 (patch) | |
tree | 794cb3b46c71c5a705f4c57f5f76c81d27e4f845 /core/reference_test.go | |
parent | 46048b6f6cbbdf20d130540e9ef823574e786240 (diff) | |
download | go-git-0ed8e180c604f8ff6d68fcaad081978a407e4653.tar.gz |
core: RefSpec support
Diffstat (limited to 'core/reference_test.go')
-rw-r--r-- | core/reference_test.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/core/reference_test.go b/core/reference_test.go index 3739a15..3d5a9b2 100644 --- a/core/reference_test.go +++ b/core/reference_test.go @@ -121,3 +121,58 @@ func (s *ReferenceSuite) TestReferenceSliceIterForEachStop(c *C) { c.Assert(count, Equals, 1) } + +func (s *ReferenceSuite) 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 *ReferenceSuite) 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 *ReferenceSuite) TestRefSpecSrc(c *C) { + spec := RefSpec("refs/heads/*:refs/remotes/origin/*") + c.Assert(spec.Src(), Equals, "refs/heads/*") +} + +func (s *ReferenceSuite) TestRefSpecMatch(c *C) { + spec := RefSpec("refs/heads/master:refs/remotes/origin/master") + c.Assert(spec.Match(ReferenceName("refs/heads/foo")), Equals, false) + c.Assert(spec.Match(ReferenceName("refs/heads/master")), Equals, true) +} + +func (s *ReferenceSuite) TestRefSpecMatchBlob(c *C) { + spec := RefSpec("refs/heads/*:refs/remotes/origin/*") + c.Assert(spec.Match(ReferenceName("refs/tag/foo")), Equals, false) + c.Assert(spec.Match(ReferenceName("refs/heads/foo")), Equals, true) +} + +func (s *ReferenceSuite) TestRefSpecDst(c *C) { + spec := RefSpec("refs/heads/master:refs/remotes/origin/master") + c.Assert( + spec.Dst(ReferenceName("refs/heads/master")).String(), Equals, + "refs/remotes/origin/master", + ) +} + +func (s *ReferenceSuite) TestRefSpecDstBlob(c *C) { + spec := RefSpec("refs/heads/*:refs/remotes/origin/*") + c.Assert( + spec.Dst(ReferenceName("refs/heads/foo")).String(), Equals, + "refs/remotes/origin/foo", + ) +} |