mirror of
https://github.com/minio/minio.git
synced 2025-12-02 06:07:51 -05:00
Inmemory donutbox is now thread safe
This commit is contained in:
@@ -3,9 +3,8 @@ package donutmem
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"bytes"
|
||||
. "gopkg.in/check.v1"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) { TestingT(t) }
|
||||
@@ -15,30 +14,27 @@ type MySuite struct{}
|
||||
var _ = Suite(&MySuite{})
|
||||
|
||||
func (s *MySuite) TestAPISuite(c *C) {
|
||||
c.Skip("Not implemented")
|
||||
data := "Hello World"
|
||||
donut := NewDonutMem()
|
||||
|
||||
writer, ch, err := donut.GetObjectWriter("foo", "bar", 0, 2)
|
||||
c.Assert(writer, IsNil)
|
||||
c.Assert(ch, IsNil)
|
||||
writer := donut.GetObjectWriter("foo", "bar", 0, 2)
|
||||
count, err := writer.Write([]byte("hello"))
|
||||
c.Assert(err, Not(IsNil))
|
||||
|
||||
err = donut.CreateBucket("foo")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
writer, ch, err = donut.GetObjectWriter("foo", "bar", 0, 2)
|
||||
writer = donut.GetObjectWriter("foo", "bar", 0, 2)
|
||||
count, err = writer.Write([]byte(data))
|
||||
c.Assert(count, Equals, len(data))
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(ch, Not(IsNil))
|
||||
writer.Write([]byte("Hello World"))
|
||||
writer.Close()
|
||||
res := <-ch
|
||||
c.Assert(res.Err, IsNil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
// time.Sleep(1 * time.Second)
|
||||
|
||||
reader, err := donut.GetObjectReader("foo", "bar", 0)
|
||||
c.Assert(err, IsNil)
|
||||
var target bytes.Buffer
|
||||
_, err = io.Copy(&target, reader)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(target.Bytes(), DeepEquals, []byte("Hello World"))
|
||||
|
||||
result, err := ioutil.ReadAll(reader)
|
||||
c.Assert(result, DeepEquals, []byte(data))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user