From 87b70781ab9ff69811999396d76ca7dfdf6de24b Mon Sep 17 00:00:00 2001 From: Alan Cabrera Date: Wed, 14 Mar 2018 09:33:54 -0700 Subject: Add more unit tests for RefSpec Need this to get better code coverage of the bug fix. Signed-off-by: Alan Cabrera --- config/refspec_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'config') diff --git a/config/refspec_test.go b/config/refspec_test.go index 6daddb4..675e075 100644 --- a/config/refspec_test.go +++ b/config/refspec_test.go @@ -62,11 +62,17 @@ func (s *RefSpecSuite) TestRefSpecSrc(c *C) { spec := RefSpec("refs/heads/*:refs/remotes/origin/*") c.Assert(spec.Src(), Equals, "refs/heads/*") + spec = RefSpec("+refs/heads/*:refs/remotes/origin/*") + c.Assert(spec.Src(), Equals, "refs/heads/*") + spec = RefSpec(":refs/heads/master") c.Assert(spec.Src(), Equals, "") spec = RefSpec("refs/heads/love+hate:refs/heads/love+hate") c.Assert(spec.Src(), Equals, "refs/heads/love+hate") + + spec = RefSpec("+refs/heads/love+hate:refs/heads/love+hate") + c.Assert(spec.Src(), Equals, "refs/heads/love+hate") } func (s *RefSpecSuite) TestRefSpecMatch(c *C) { @@ -74,12 +80,19 @@ func (s *RefSpecSuite) TestRefSpecMatch(c *C) { 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: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) spec = RefSpec("refs/heads/love+hate:heads/love+hate") c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/love+hate")), Equals, true) + + spec = RefSpec("+refs/heads/love+hate:heads/love+hate") + c.Assert(spec.Match(plumbing.ReferenceName("refs/heads/love+hate")), Equals, true) } func (s *RefSpecSuite) TestRefSpecMatchGlob(c *C) { -- cgit