aboutsummaryrefslogtreecommitdiffstats
path: root/core/reference_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/reference_test.go')
-rw-r--r--core/reference_test.go55
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",
+ )
+}