aboutsummaryrefslogtreecommitdiffstats
path: root/difftree/internal/merkletrie/frame_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-14 23:12:44 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-14 23:12:44 +0100
commit0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 (patch)
tree49e81e74e82d84fd88b2fc1e4b0dc7c7bfe9c40f /difftree/internal/merkletrie/frame_test.go
parentdf0f38af83f972f026d7e14150f3d37b95f13484 (diff)
downloadgo-git-0af572dd21c0aa79d13745b633ee24ba6c4d6cf1.tar.gz
move plumbing from top level package to plumbing (#183)
* plumbing: rename Object -> EncodedObject. * plumbing/storer: rename ObjectStorer -> EncodedObjectStorer. * move difftree to plumbing/difftree. * move diff -> utils/diff * make Object/Tag/Blob/Tree/Commit/File depend on storer. * Object and its implementations now depend only on storer.EncodedObjectStorer, not git.Repository. * Tests are decoupled accordingly. * move Object/Commit/File/Tag/Tree to plumbing/object. * move Object/Commit/File/Tag/Tree to plumbing/object. * move checkClose to utils/ioutil. * move RevListObjects to plumbing/revlist.Objects. * move DiffTree to plumbing/difftree package. * rename files with plural nouns to singular * plumbing/object: add GetBlob/GetCommit/GetTag/GetTree.
Diffstat (limited to 'difftree/internal/merkletrie/frame_test.go')
-rw-r--r--difftree/internal/merkletrie/frame_test.go69
1 files changed, 0 insertions, 69 deletions
diff --git a/difftree/internal/merkletrie/frame_test.go b/difftree/internal/merkletrie/frame_test.go
deleted file mode 100644
index 0ef036a..0000000
--- a/difftree/internal/merkletrie/frame_test.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package merkletrie
-
-import . "gopkg.in/check.v1"
-
-type FrameSuite struct{}
-
-var _ = Suite(&FrameSuite{})
-
-func (s *FrameSuite) TestNewFrameFromLeaf(c *C) {
- n := newNode(
- []byte("hash"),
- "key",
- []*node{},
- )
-
- frame := newFrame("foo", n)
-
- expectedString := `base="foo/key", stack=[]`
- c.Assert(frame.String(), Equals, expectedString)
-
- obtainedTopNode, obtainedTopOK := frame.top()
- c.Assert(obtainedTopNode, IsNil)
- c.Assert(obtainedTopOK, Equals, false)
-
- obtainedPopNode, obtainedPopOK := frame.top()
- c.Assert(obtainedPopNode, IsNil)
- c.Assert(obtainedPopOK, Equals, false)
-}
-
-func (s *FrameSuite) TestNewFrameFromParent(c *C) {
- leaf0 := newNode([]byte("leaf0 hash"), "leaf0 key", []*node{})
- leaf1 := newNode([]byte("leaf1 hash"), "leaf1 key", []*node{})
- leaf2 := newNode([]byte("leaf2 hash"), "leaf2 key", []*node{})
- leaf3 := newNode([]byte("leaf3 hash"), "leaf3 key", []*node{})
- parent := newNode(
- []byte("parent hash"),
- "parent key",
- []*node{leaf3, leaf0, leaf2, leaf1}, // not alphabetically sorted
- )
-
- frame := newFrame("foo", parent)
-
- expectedString := `base="foo/parent key", stack=["leaf3 key", "leaf2 key", "leaf1 key", "leaf0 key"]`
- c.Assert(frame.String(), Equals, expectedString)
-
- checkTopAndPop(c, frame, leaf0, true)
- checkTopAndPop(c, frame, leaf1, true)
- checkTopAndPop(c, frame, leaf2, true)
- checkTopAndPop(c, frame, leaf3, true)
- checkTopAndPop(c, frame, nil, false)
-}
-
-func checkTopAndPop(c *C, f *frame, expectedNode *node, expectedOK bool) {
- n, ok := f.top()
- if expectedNode == nil {
- c.Assert(n, IsNil)
- } else {
- c.Assert(n, DeepEquals, expectedNode)
- }
- c.Assert(ok, Equals, expectedOK)
-
- n, ok = f.pop()
- if expectedNode == nil {
- c.Assert(n, IsNil)
- } else {
- c.Assert(n, DeepEquals, expectedNode)
- }
- c.Assert(ok, Equals, expectedOK)
-}