aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/tree_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/object/tree_test.go')
-rw-r--r--plumbing/object/tree_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/plumbing/object/tree_test.go b/plumbing/object/tree_test.go
index 00601c1..9b9614b 100644
--- a/plumbing/object/tree_test.go
+++ b/plumbing/object/tree_test.go
@@ -48,6 +48,31 @@ func (s *TreeSuite) TestType(c *C) {
c.Assert(s.Tree.Type(), Equals, plumbing.TreeObject)
}
+func (s *TreeSuite) TestTree(c *C) {
+ expectedEntry, ok := s.Tree.m["vendor"]
+ c.Assert(ok, Equals, true)
+ expected := expectedEntry.Hash
+
+ obtainedTree, err := s.Tree.Tree("vendor")
+ c.Assert(err, IsNil)
+ c.Assert(obtainedTree.Hash, Equals, expected)
+}
+
+func (s *TreeSuite) TestTreeNotFound(c *C) {
+ d, err := s.Tree.Tree("not-found")
+ c.Assert(d, IsNil)
+ c.Assert(err, Equals, ErrDirectoryNotFound)
+}
+
+func (s *TreeSuite) TestTreeFailsWithExistingFiles(c *C) {
+ _, err := s.Tree.File("LICENSE")
+ c.Assert(err, IsNil)
+
+ d, err := s.Tree.Tree("LICENSE")
+ c.Assert(d, IsNil)
+ c.Assert(err, Equals, ErrDirectoryNotFound)
+}
+
func (s *TreeSuite) TestFile(c *C) {
f, err := s.Tree.File("LICENSE")
c.Assert(err, IsNil)
@@ -60,6 +85,15 @@ func (s *TreeSuite) TestFileNotFound(c *C) {
c.Assert(err, Equals, ErrFileNotFound)
}
+func (s *TreeSuite) TestFileFailsWithExistingTrees(c *C) {
+ _, err := s.Tree.Tree("vendor")
+ c.Assert(err, IsNil)
+
+ f, err := s.Tree.File("vendor")
+ c.Assert(f, IsNil)
+ c.Assert(err, Equals, ErrFileNotFound)
+}
+
func (s *TreeSuite) TestFiles(c *C) {
var count int
err := s.Tree.Files().ForEach(func(f *File) error {