Merge pull request #297 from fkautz/pr_out_more_testing

This commit is contained in:
Frederick F. Kautz IV 2015-03-14 19:30:02 -07:00
commit e601d997f3
2 changed files with 25 additions and 3 deletions

View File

@ -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")
}

View File

@ -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))
}