diff --git a/pkg/donutbox/donutmem/donutmem.go b/pkg/donutbox/donutmem/donutmem.go index 8724130f4..67b871f22 100644 --- a/pkg/donutbox/donutmem/donutmem.go +++ b/pkg/donutbox/donutmem/donutmem.go @@ -59,12 +59,15 @@ func (donutMem donutMem) CreateBucket(b string) error { donutMem.buckets[b] = &newBucket return nil } + func (donutMem donutMem) ListObjects(bucket, prefix string) ([]string, error) { return nil, errors.New("Not Implemented") } + func (donutMem donutMem) GetBucketMetadata(bucket, name string) (io.Reader, error) { return nil, errors.New("Not Implemented") } + func (donutMem donutMem) SetBucketMetadata(bucket, name string, metadata io.Reader) error { return errors.New("Not Implemented") } @@ -117,6 +120,7 @@ func (donutMem donutMem) GetObjectWriter(bucket, key string, column uint, blockS writer.CloseWithError(errors.New("Bucket does not exist")) return writer } + func (donutMem donutMem) GetObjectReader(bucket, key string, column int) (io.Reader, error) { donutMem.lock.RLock() defer donutMem.lock.RUnlock() @@ -132,9 +136,11 @@ func (donutMem donutMem) GetObjectReader(bucket, key string, column int) (io.Rea } return nil, errors.New("Bucket not found") } + func (donutMem donutMem) StoreObjectMetadata(bucket, object, name string, reader io.Reader) error { return errors.New("Not Implemented") } + func (donutMem donutMem) GetObjectMetadata(bucket, object, name string) (io.Reader, error) { return nil, errors.New("Not Implemented") } diff --git a/pkg/donutbox/donutmem/donutmem_test.go b/pkg/donutbox/donutmem/donutmem_test.go index 217b970aa..e3ecadd5a 100644 --- a/pkg/donutbox/donutmem/donutmem_test.go +++ b/pkg/donutbox/donutmem/donutmem_test.go @@ -28,13 +28,29 @@ func (s *MySuite) TestAPISuite(c *C) { count, err = writer.Write([]byte(data)) c.Assert(count, Equals, len(data)) c.Assert(err, IsNil) - writer.Close() + err = writer.Close() c.Assert(err, IsNil) - // time.Sleep(1 * time.Second) - + // data should be available reader, err := donut.GetObjectReader("foo", "bar", 0) c.Assert(err, IsNil) result, err := ioutil.ReadAll(reader) c.Assert(result, DeepEquals, []byte(data)) + + // try writing, should see error + writer = donut.GetObjectWriter("foo", "bar", 0, 2) + count, err = writer.Write([]byte("different data")) + c.Assert(count, Equals, 0) + c.Assert(err, Not(IsNil)) + // try again, should see error + count, err = writer.Write([]byte("different data")) + c.Assert(count, Equals, 0) + c.Assert(err, Not(IsNil)) + + // data should not change + reader, err = donut.GetObjectReader("foo", "bar", 0) + c.Assert(err, IsNil) + result, err = ioutil.ReadAll(reader) + c.Assert(result, DeepEquals, []byte(data)) + }