diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-25 10:18:48 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-02-25 10:18:48 +0100 |
commit | 5bc563727ffa798caee3b007c366eb66c3d69caa (patch) | |
tree | 6107f49405bb605793f1bcd7ef4961ceadcb11e9 /objects_test.go | |
parent | 07ca1ac7f3058ea6d3274a01973541fb84782f5e (diff) | |
parent | 0d999e1db6cd8736ab697de8ce848fa3a5274b9f (diff) | |
download | go-git-5bc563727ffa798caee3b007c366eb66c3d69caa.tar.gz |
Merge pull request #34 from scjalliance/object-reader-writer
Refactor to use core.ObjectReader and core.ObjectWriter
Diffstat (limited to 'objects_test.go')
-rw-r--r-- | objects_test.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/objects_test.go b/objects_test.go index 10b9661..6826957 100644 --- a/objects_test.go +++ b/objects_test.go @@ -67,7 +67,10 @@ func (s *ObjectsSuite) TestParseTree(c *C) { for f, err := iter.Next(); err == nil; f, err = iter.Next() { count++ if f.Name == "go/example.go" { - content, _ := ioutil.ReadAll(f.Reader()) + reader, err := f.Reader() + c.Assert(err, IsNil) + defer func() { c.Assert(reader.Close(), IsNil) }() + content, _ := ioutil.ReadAll(reader) c.Assert(content, HasLen, 2780) } } @@ -79,7 +82,12 @@ func (s *ObjectsSuite) TestBlobHash(c *C) { o := &memory.Object{} o.SetType(core.BlobObject) o.SetSize(3) - o.Writer().Write([]byte{'F', 'O', 'O'}) + + writer, err := o.Writer() + c.Assert(err, IsNil) + defer func() { c.Assert(writer.Close(), IsNil) }() + + writer.Write([]byte{'F', 'O', 'O'}) blob := &Blob{} c.Assert(blob.Decode(o), IsNil) @@ -87,7 +95,11 @@ func (s *ObjectsSuite) TestBlobHash(c *C) { c.Assert(blob.Size, Equals, int64(3)) c.Assert(blob.Hash.String(), Equals, "d96c7efbfec2814ae0301ad054dc8d9fc416c9b5") - data, err := ioutil.ReadAll(blob.Reader()) + reader, err := blob.Reader() + c.Assert(err, IsNil) + defer func() { c.Assert(reader.Close(), IsNil) }() + + data, err := ioutil.ReadAll(reader) c.Assert(err, IsNil) c.Assert(string(data), Equals, "FOO") } |