diff options
Diffstat (limited to 'storage/memory/object_test.go')
-rw-r--r-- | storage/memory/object_test.go | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/storage/memory/object_test.go b/storage/memory/object_test.go deleted file mode 100644 index c252626..0000000 --- a/storage/memory/object_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package memory - -import ( - "io/ioutil" - "testing" - - . "gopkg.in/check.v1" - "gopkg.in/src-d/go-git.v4/core" -) - -func Test(t *testing.T) { TestingT(t) } - -type ObjectSuite struct{} - -var _ = Suite(&ObjectSuite{}) - -func (s *ObjectSuite) TestHash(c *C) { - o := &Object{} - o.SetType(core.BlobObject) - o.SetSize(14) - - _, err := o.Write([]byte("Hello, World!\n")) - c.Assert(err, IsNil) - - c.Assert(o.Hash().String(), Equals, "8ab686eafeb1f44702738c8b0f24f2567c36da6d") - - o.SetType(core.CommitObject) - c.Assert(o.Hash().String(), Equals, "8ab686eafeb1f44702738c8b0f24f2567c36da6d") -} - -func (s *ObjectSuite) TestHashNotFilled(c *C) { - o := &Object{} - o.SetType(core.BlobObject) - o.SetSize(14) - - c.Assert(o.Hash(), Equals, core.ZeroHash) -} - -func (s *ObjectSuite) TestType(c *C) { - o := &Object{} - o.SetType(core.BlobObject) - c.Assert(o.Type(), Equals, core.BlobObject) -} - -func (s *ObjectSuite) TestSize(c *C) { - o := &Object{} - o.SetSize(42) - c.Assert(o.Size(), Equals, int64(42)) -} - -func (s *ObjectSuite) TestReader(c *C) { - o := &Object{cont: []byte("foo")} - - reader, err := o.Reader() - c.Assert(err, IsNil) - defer func() { c.Assert(reader.Close(), IsNil) }() - - b, err := ioutil.ReadAll(reader) - c.Assert(err, IsNil) - c.Assert(b, DeepEquals, []byte("foo")) -} - -func (s *ObjectSuite) TestWriter(c *C) { - o := &Object{} - - writer, err := o.Writer() - c.Assert(err, IsNil) - defer func() { c.Assert(writer.Close(), IsNil) }() - - n, err := writer.Write([]byte("foo")) - c.Assert(err, IsNil) - c.Assert(n, Equals, 3) - - c.Assert(o.cont, DeepEquals, []byte("foo")) -} |