aboutsummaryrefslogtreecommitdiffstats
path: root/storage/memory/storage_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-02-17 00:24:31 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-02-17 11:46:00 +0100
commita964e32d92c53a47ce7c46d589a18c62133b8c50 (patch)
tree4c094cd6afb95cb2832f866b9411276418435819 /storage/memory/storage_test.go
parent1ac00554c3b5f88d2ddc2e28e7cfcdcad9d9f4bb (diff)
downloadgo-git-a964e32d92c53a47ce7c46d589a18c62133b8c50.tar.gz
storages: memory object
Diffstat (limited to 'storage/memory/storage_test.go')
-rw-r--r--storage/memory/storage_test.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/storage/memory/storage_test.go b/storage/memory/storage_test.go
new file mode 100644
index 0000000..4059dfa
--- /dev/null
+++ b/storage/memory/storage_test.go
@@ -0,0 +1,51 @@
+package memory
+
+import (
+ . "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git.v2/core"
+)
+
+type ObjectStorageSuite struct{}
+
+var _ = Suite(&ObjectStorageSuite{})
+
+func (s *ObjectStorageSuite) TestNew(c *C) {
+ os := NewObjectStorage()
+
+ o, err := os.New()
+ c.Assert(err, IsNil)
+ c.Assert(o.Size(), Equals, int64(0))
+}
+
+func (s *ObjectStorageSuite) TestSet(c *C) {
+ os := NewObjectStorage()
+
+ o, err := os.New()
+ c.Assert(err, IsNil)
+
+ o.SetType(core.CommitObject)
+ o.SetSize(3)
+ o.Writer().Write([]byte("foo"))
+
+ h, err := os.Set(o)
+ c.Assert(h.String(), Equals, "bc9968d75e48de59f0870ffb71f5e160bbbdcf52")
+}
+
+func (s *ObjectStorageSuite) TestGet(c *C) {
+ os := NewObjectStorage()
+
+ o, err := os.New()
+ c.Assert(err, IsNil)
+
+ o.SetType(core.CommitObject)
+ o.SetSize(3)
+ o.Writer().Write([]byte("foo"))
+
+ h, err := os.Set(o)
+ c.Assert(err, IsNil)
+
+ ro, err := os.Get(h)
+ c.Assert(err, IsNil)
+
+ c.Assert(ro, DeepEquals, o)
+}