diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-11-08 23:46:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-08 23:46:38 +0100 |
commit | ac095bb12c4d29722b60ba9f20590fa7cfa6bc7d (patch) | |
tree | 223f36f336ba3414b1e45cac8af6c4744a5d7ef6 /plumbing/reference_test.go | |
parent | e523701393598f4fa241dd407af9ff8925507a1a (diff) | |
download | go-git-ac095bb12c4d29722b60ba9f20590fa7cfa6bc7d.tar.gz |
new plumbing package (#118)
* plumbing: now core was renamed to core, and formats and clients moved inside
Diffstat (limited to 'plumbing/reference_test.go')
-rw-r--r-- | plumbing/reference_test.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/plumbing/reference_test.go b/plumbing/reference_test.go new file mode 100644 index 0000000..4d9b393 --- /dev/null +++ b/plumbing/reference_test.go @@ -0,0 +1,61 @@ +package plumbing + +import . "gopkg.in/check.v1" + +type ReferenceSuite struct{} + +var _ = Suite(&ReferenceSuite{}) + +const ( + ExampleReferenceName ReferenceName = "refs/heads/v4" +) + +func (s *ReferenceSuite) TestReferenceNameShort(c *C) { + c.Assert(ExampleReferenceName.Short(), Equals, "v4") +} + +func (s *ReferenceSuite) TestNewReferenceFromStrings(c *C) { + r := NewReferenceFromStrings("refs/heads/v4", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") + c.Assert(r.Type(), Equals, HashReference) + c.Assert(r.Name(), Equals, ExampleReferenceName) + c.Assert(r.Hash(), Equals, NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + + r = NewReferenceFromStrings("HEAD", "ref: refs/heads/v4") + c.Assert(r.Type(), Equals, SymbolicReference) + c.Assert(r.Name(), Equals, HEAD) + c.Assert(r.Target(), Equals, ExampleReferenceName) +} + +func (s *ReferenceSuite) TestNewSymbolicReference(c *C) { + r := NewSymbolicReference(HEAD, ExampleReferenceName) + c.Assert(r.Type(), Equals, SymbolicReference) + c.Assert(r.Name(), Equals, HEAD) + c.Assert(r.Target(), Equals, ExampleReferenceName) +} + +func (s *ReferenceSuite) TestNewHashReference(c *C) { + r := NewHashReference(ExampleReferenceName, NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) + c.Assert(r.Type(), Equals, HashReference) + c.Assert(r.Name(), Equals, ExampleReferenceName) + c.Assert(r.Hash(), Equals, NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) +} + +func (s *ReferenceSuite) TestIsBranch(c *C) { + r := NewHashReference(ExampleReferenceName, ZeroHash) + c.Assert(r.IsBranch(), Equals, true) +} + +func (s *ReferenceSuite) TestIsNote(c *C) { + r := NewHashReference(ReferenceName("refs/notes/foo"), ZeroHash) + c.Assert(r.IsNote(), Equals, true) +} + +func (s *ReferenceSuite) TestIsRemote(c *C) { + r := NewHashReference(ReferenceName("refs/remotes/origin/master"), ZeroHash) + c.Assert(r.IsRemote(), Equals, true) +} + +func (s *ReferenceSuite) TestIsTag(c *C) { + r := NewHashReference(ReferenceName("refs/tags/v3.1."), ZeroHash) + c.Assert(r.IsTag(), Equals, true) +} |