|
|
@ -19,6 +19,9 @@ package v1 |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
. "gopkg.in/check.v1" |
|
|
|
. "gopkg.in/check.v1" |
|
|
|
|
|
|
|
"io" |
|
|
|
|
|
|
|
"io/ioutil" |
|
|
|
|
|
|
|
"os" |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -29,23 +32,33 @@ type MySuite struct{} |
|
|
|
var _ = Suite(&MySuite{}) |
|
|
|
var _ = Suite(&MySuite{}) |
|
|
|
|
|
|
|
|
|
|
|
func (s *MySuite) TestAPISuite(c *C) { |
|
|
|
func (s *MySuite) TestAPISuite(c *C) { |
|
|
|
var b bytes.Buffer |
|
|
|
var b io.ReadWriteSeeker |
|
|
|
var o bytes.Buffer |
|
|
|
var o bytes.Buffer |
|
|
|
|
|
|
|
|
|
|
|
donut := New(&b) |
|
|
|
b, err := ioutil.TempFile(os.TempDir(), "minio-donut-test") |
|
|
|
|
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
donut := New(b) |
|
|
|
gobheader := GobHeader{} |
|
|
|
gobheader := GobHeader{} |
|
|
|
err := donut.Write(gobheader, &o) |
|
|
|
err = donut.Write(gobheader, &o) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
blockStart := make([]byte, 4) |
|
|
|
blockStart := make([]byte, 4) |
|
|
|
blockEnd := make([]byte, 4) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n, _ := b.Read(blockStart) |
|
|
|
|
|
|
|
b.Next(b.Len() - n) // jump ahead
|
|
|
|
|
|
|
|
b.Read(blockEnd) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//n, _ := b.Read(blockStart)
|
|
|
|
|
|
|
|
// b.Next(b.Len() - n) // jump ahead
|
|
|
|
|
|
|
|
// b.Read(blockEnd)
|
|
|
|
|
|
|
|
// read start
|
|
|
|
|
|
|
|
b.Seek(0, 0) // jump ahead
|
|
|
|
|
|
|
|
b.Read(blockStart) |
|
|
|
blockStartCheck := []byte{'M', 'I', 'N', 'I'} |
|
|
|
blockStartCheck := []byte{'M', 'I', 'N', 'I'} |
|
|
|
blockEndCheck := []byte{'I', 'N', 'I', 'M'} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c.Assert(blockStart, DeepEquals, blockStartCheck) |
|
|
|
c.Assert(blockStart, DeepEquals, blockStartCheck) |
|
|
|
c.Assert(blockEnd, DeepEquals, blockEndCheck) |
|
|
|
|
|
|
|
|
|
|
|
// read block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// read end
|
|
|
|
|
|
|
|
// blockEnd := make([]byte, 4)
|
|
|
|
|
|
|
|
// b.Seek(int64(len(blockEnd)), 2) // jump ahead
|
|
|
|
|
|
|
|
// b.Read(blockEnd)
|
|
|
|
|
|
|
|
// blockEndCheck := []byte{'I', 'N', 'I', 'M'}
|
|
|
|
|
|
|
|
// c.Assert(blockEnd, DeepEquals, blockEndCheck)
|
|
|
|
} |
|
|
|
} |
|
|
|