diff options
Diffstat (limited to 'formats/objfile/writer_test.go')
-rw-r--r-- | formats/objfile/writer_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/formats/objfile/writer_test.go b/formats/objfile/writer_test.go index 03b8370..0061f3f 100644 --- a/formats/objfile/writer_test.go +++ b/formats/objfile/writer_test.go @@ -38,9 +38,12 @@ func testWriter(c *C, dest io.Writer, hash core.Hash, typ core.ObjectType, conte written, err := io.Copy(w, bytes.NewReader(content)) c.Assert(err, IsNil) c.Assert(written, Equals, length) + c.Assert(w.Size(), Equals, int64(len(content))) c.Assert(w.Hash(), Equals, hash) // Test Hash() before close c.Assert(w.Close(), IsNil) c.Assert(w.Hash(), Equals, hash) // Test Hash() after close + _, err = w.Write([]byte{1}) + c.Assert(err, Equals, ErrClosed) } func (s *SuiteWriter) TestWriteOverflow(c *C) { @@ -51,3 +54,16 @@ func (s *SuiteWriter) TestWriteOverflow(c *C) { _, err = w.Write([]byte("56789")) c.Assert(err, Equals, ErrOverflow) } + +func (s *SuiteWriter) TestNewWriterInvalidType(c *C) { + var t core.ObjectType + _, err := NewWriter(new(bytes.Buffer), t, 8) + c.Assert(err, Equals, core.ErrInvalidType) +} + +func (s *SuiteWriter) TestNewWriterInvalidSize(c *C) { + _, err := NewWriter(new(bytes.Buffer), core.BlobObject, -1) + c.Assert(err, Equals, ErrNegativeSize) + _, err = NewWriter(new(bytes.Buffer), core.BlobObject, -1651860) + c.Assert(err, Equals, ErrNegativeSize) +} |