diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2019-02-02 13:08:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-02 13:08:52 +0100 |
commit | d1b5bceb228e528bf085a3d4e2c35218e692da01 (patch) | |
tree | 9dadb6130108cce350f546e4e30bc421c2b422a1 /storage/transactional/shallow_test.go | |
parent | a1f6ef44dfed1253ef7f3bc049f66b15f8fc2ab2 (diff) | |
parent | 96317743391ac87aeb07d292469e212671628437 (diff) | |
download | go-git-d1b5bceb228e528bf085a3d4e2c35218e692da01.tar.gz |
Merge pull request #1006 from mcuadros/transactional-storage
storage: transactional, new storage with transactional capabilities
Diffstat (limited to 'storage/transactional/shallow_test.go')
-rw-r--r-- | storage/transactional/shallow_test.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/storage/transactional/shallow_test.go b/storage/transactional/shallow_test.go new file mode 100644 index 0000000..5141782 --- /dev/null +++ b/storage/transactional/shallow_test.go @@ -0,0 +1,62 @@ +package transactional + +import ( + . "gopkg.in/check.v1" + "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/storage/memory" +) + +var _ = Suite(&ShallowSuite{}) + +type ShallowSuite struct{} + +func (s *ShallowSuite) TestShallow(c *C) { + base := memory.NewStorage() + temporal := memory.NewStorage() + + rs := NewShallowStorage(base, temporal) + + commitA := plumbing.NewHash("bc9968d75e48de59f0870ffb71f5e160bbbdcf52") + commitB := plumbing.NewHash("aa9968d75e48de59f0870ffb71f5e160bbbdcf52") + + err := base.SetShallow([]plumbing.Hash{commitA}) + c.Assert(err, IsNil) + + err = rs.SetShallow([]plumbing.Hash{commitB}) + c.Assert(err, IsNil) + + commits, err := rs.Shallow() + c.Assert(err, IsNil) + c.Assert(commits, HasLen, 1) + c.Assert(commits[0], Equals, commitB) + + commits, err = base.Shallow() + c.Assert(err, IsNil) + c.Assert(commits, HasLen, 1) + c.Assert(commits[0], Equals, commitA) +} + +func (s *ShallowSuite) TestCommit(c *C) { + base := memory.NewStorage() + temporal := memory.NewStorage() + + rs := NewShallowStorage(base, temporal) + + commitA := plumbing.NewHash("bc9968d75e48de59f0870ffb71f5e160bbbdcf52") + commitB := plumbing.NewHash("aa9968d75e48de59f0870ffb71f5e160bbbdcf52") + + c.Assert(base.SetShallow([]plumbing.Hash{commitA}), IsNil) + c.Assert(rs.SetShallow([]plumbing.Hash{commitB}), IsNil) + + c.Assert(rs.Commit(), IsNil) + + commits, err := rs.Shallow() + c.Assert(err, IsNil) + c.Assert(commits, HasLen, 1) + c.Assert(commits[0], Equals, commitB) + + commits, err = base.Shallow() + c.Assert(err, IsNil) + c.Assert(commits, HasLen, 1) + c.Assert(commits[0], Equals, commitB) +} |