diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-13 00:15:19 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-13 00:15:19 +0100 |
commit | b18d6490aefe8509791843136530e3426d0c8200 (patch) | |
tree | 64cbc583f64483f667234833a8bf4abc7f5c0084 /plumbing/object/tree_test.go | |
parent | b3b6e51565dcdbf81546f1d8f0121874a4e4fce9 (diff) | |
download | go-git-b18d6490aefe8509791843136530e3426d0c8200.tar.gz |
plumbing/object: allow TreeIter return SubModule entries
Diffstat (limited to 'plumbing/object/tree_test.go')
-rw-r--r-- | plumbing/object/tree_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/plumbing/object/tree_test.go b/plumbing/object/tree_test.go index be721b9..0ddf391 100644 --- a/plumbing/object/tree_test.go +++ b/plumbing/object/tree_test.go @@ -4,7 +4,10 @@ import ( "io" "os" + fixtures "github.com/src-d/go-git-fixtures" + "srcd.works/go-git.v4/plumbing" + "srcd.works/go-git.v4/storage/filesystem" . "gopkg.in/check.v1" "srcd.works/go-git.v4/plumbing/storer" @@ -262,6 +265,41 @@ func (s *TreeSuite) TestTreeWalkerNextNonRecursive(c *C) { c.Assert(count, Equals, 8) } +func (s *TreeSuite) TestTreeWalkerNextSubmodule(c *C) { + st, err := filesystem.NewStorage(fixtures.ByTag("submodule").One().DotGit()) + c.Assert(err, IsNil) + + hash := plumbing.NewHash("a692ec699bff9117c1ed91752afbb7d9d272ebef") + commit, err := GetCommit(st, hash) + c.Assert(err, IsNil) + + tree, err := commit.Tree() + c.Assert(err, IsNil) + + expected := []string{ + ".gitmodules", + "basic", + "itself", + } + + var count int + walker := NewTreeWalker(tree, true) + for { + name, entry, err := walker.Next() + if err == io.EOF { + break + } + + c.Assert(err, IsNil) + c.Assert(entry, NotNil) + c.Assert(name, Equals, expected[count]) + + count++ + } + + c.Assert(count, Equals, 3) +} + var treeWalkerExpects = []struct { Path, Mode, Name, Hash, Tree string }{{ |