diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-17 23:45:06 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-17 23:45:06 +0100 |
commit | f57aa864e2b3c721d9511a2d78f0c0106e42677a (patch) | |
tree | 0cc85b4632818b7e9dd72d27a10698843304837b /objects_test.go | |
parent | 6b0a5984ac0c69742e60a39ad9437fd981dbe31b (diff) | |
parent | a72c4ec54bb0502bd230dd007ebd1ef7b381afc7 (diff) | |
download | go-git-f57aa864e2b3c721d9511a2d78f0c0106e42677a.tar.gz |
Merge pull request #30 from scjalliance/consistent-iterators
Improved consistency of Tree iterators
Diffstat (limited to 'objects_test.go')
-rw-r--r-- | objects_test.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/objects_test.go b/objects_test.go index e8c5d6e..4745774 100644 --- a/objects_test.go +++ b/objects_test.go @@ -6,7 +6,7 @@ import ( . "gopkg.in/check.v1" "gopkg.in/src-d/go-git.v3/core" - "gopkg.in/src-d/go-git.v3/storages/memory" + "gopkg.in/src-d/go-git.v3/storage/memory" ) type ObjectsSuite struct { @@ -54,13 +54,17 @@ func (s *ObjectsSuite) TestParseTree(c *C) { c.Assert(err, IsNil) c.Assert(tree.Entries, HasLen, 8) - c.Assert(tree.Entries[".gitignore"].Name, Equals, ".gitignore") - c.Assert(tree.Entries[".gitignore"].Mode.String(), Equals, "-rw-r--r--") - c.Assert(tree.Entries[".gitignore"].Hash.String(), Equals, "32858aad3c383ed1ff0a0f9bdf231d54a00c9e88") + + tree.buildMap() + c.Assert(tree.m, HasLen, 8) + c.Assert(tree.m[".gitignore"].Name, Equals, ".gitignore") + c.Assert(tree.m[".gitignore"].Mode.String(), Equals, "-rw-r--r--") + c.Assert(tree.m[".gitignore"].Hash.String(), Equals, "32858aad3c383ed1ff0a0f9bdf231d54a00c9e88") count := 0 - ch := tree.Files() - for f := range ch { + iter := tree.Files() + defer iter.Close() + for f, err := iter.Next(); err == nil; f, err = iter.Next() { count++ if f.Name == "go/example.go" { content, _ := ioutil.ReadAll(f) |