@ -167,8 +167,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
Size : 0 ,
}
typedDriver . On ( "CreateBucket" , "bucket" , "private" ) . Return ( nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object" , "" ) . Return ( metadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object" , "" , "" , mock . Anything ) . Return ( metadata . Md5 , nil ) . Once ( )
typedDriver . On ( "GetBucketMetadata" , "bucket" ) . Return ( drivers . BucketMetadata { } , nil ) . Twice ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object" , "" ) . Return ( metadata , nil ) . Once ( )
typedDriver . On ( "GetObject" , mock . Anything , "bucket" , "object" ) . Return ( int64 ( 0 ) , nil ) . Once ( )
@ -180,7 +179,6 @@ func (s *MySuite) TestEmptyObject(c *C) {
buffer := bytes . NewBufferString ( "" )
driver . CreateBucket ( "bucket" , "private" )
driver . CreateObject ( "bucket" , "object" , "" , "" , buffer )
driver . GetObjectMetadata ( "bucket" , "object" , "" )
request , err := http . NewRequest ( "GET" , testServer . URL + "/bucket/object" , nil )
c . Assert ( err , IsNil )
@ -251,8 +249,7 @@ func (s *MySuite) TestObject(c *C) {
Size : 11 ,
}
typedDriver . On ( "CreateBucket" , "bucket" , "private" ) . Return ( nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object" , "" ) . Return ( metadata , nil ) . Twice ( )
typedDriver . On ( "CreateObject" , "bucket" , "object" , "" , "" , mock . Anything ) . Return ( metadata . Md5 , nil ) . Once ( )
typedDriver . On ( "GetBucketMetadata" , "bucket" ) . Return ( drivers . BucketMetadata { } , nil ) . Twice ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object" , "" ) . Return ( metadata , nil ) . Twice ( )
typedDriver . SetGetObjectWriter ( "bucket" , "object" , [ ] byte ( "hello world" ) )
@ -265,7 +262,6 @@ func (s *MySuite) TestObject(c *C) {
buffer := bytes . NewBufferString ( "hello world" )
driver . CreateBucket ( "bucket" , "private" )
driver . CreateObject ( "bucket" , "object" , "" , "" , buffer )
driver . GetObjectMetadata ( "bucket" , "object" , "" )
request , err := http . NewRequest ( "GET" , testServer . URL + "/bucket/object" , nil )
c . Assert ( err , IsNil )
@ -328,18 +324,12 @@ func (s *MySuite) TestMultipleObjects(c *C) {
typedDriver . On ( "CreateBucket" , "bucket" , "private" ) . Return ( nil ) . Once ( )
driver . CreateBucket ( "bucket" , "private" )
typedDriver . On ( "CreateObject" , "bucket" , "object1" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object1" , "" ) . Return ( metadata1 , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object1" , "" , "" , mock . Anything ) . Return ( metadata1 . Md5 , nil ) . Once ( )
driver . CreateObject ( "bucket" , "object1" , "" , "" , buffer1 )
driver . GetObjectMetadata ( "bucket" , "object1" , "" )
typedDriver . On ( "CreateObject" , "bucket" , "object2" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object2" , "" ) . Return ( metadata2 , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object2" , "" , "" , mock . Anything ) . Return ( metadata2 . Md5 , nil ) . Once ( )
driver . CreateObject ( "bucket" , "object2" , "" , "" , buffer2 )
driver . GetObjectMetadata ( "bucket" , "object2" , "" )
typedDriver . On ( "CreateObject" , "bucket" , "object3" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object3" , "" ) . Return ( metadata3 , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object3" , "" , "" , mock . Anything ) . Return ( metadata3 . Md5 , nil ) . Once ( )
driver . CreateObject ( "bucket" , "object3" , "" , "" , buffer3 )
driver . GetObjectMetadata ( "bucket" , "object3" , "" )
// test non-existant object
typedDriver . On ( "GetBucketMetadata" , "bucket" ) . Return ( drivers . BucketMetadata { } , nil ) . Once ( )
@ -515,10 +505,8 @@ func (s *MySuite) TestHeader(c *C) {
buffer := bytes . NewBufferString ( "hello world" )
typedDriver . On ( "GetBucketMetadata" , "foo" ) . Return ( bucketMetadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object" , "" ) . Return ( objectMetadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "object" , "" , "" , mock . Anything ) . Return ( objectMetadata . Md5 , nil ) . Once ( )
driver . CreateObject ( "bucket" , "object" , "" , "" , buffer )
driver . GetObjectMetadata ( "bucket" , "object" , "" )
typedDriver . On ( "GetBucketMetadata" , "bucket" ) . Return ( bucketMetadata , nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "object" , "" ) . Return ( objectMetadata , nil ) . Once ( )
@ -629,8 +617,7 @@ func (s *MySuite) TestPutObject(c *C) {
Size : 11 ,
}
typedDriver . On ( "CreateObject" , "bucket" , "two" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "two" , "" ) . Return ( twoMetadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "two" , "" , "" , mock . Anything ) . Return ( twoMetadata . Md5 , nil ) . Once ( )
request , err = http . NewRequest ( "PUT" , testServer . URL + "/bucket/two" , bytes . NewBufferString ( "hello world" ) )
c . Assert ( err , IsNil )
setAuthHeader ( request )
@ -917,8 +904,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
}
typedDriver . On ( "GetBucketMetadata" , "bucket" ) . Return ( metadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "one" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "one" , "" ) . Return ( oneMetadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "one" , "" , "" , mock . Anything ) . Return ( oneMetadata . Md5 , nil ) . Once ( )
request , err := http . NewRequest ( "PUT" , testServer . URL + "/bucket/one" , bytes . NewBufferString ( "hello world" ) )
delete ( request . Header , "Content-Type" )
c . Assert ( err , IsNil )
@ -965,8 +951,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
}
typedDriver . On ( "GetBucketMetadata" , "bucket" ) . Return ( metadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "two" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "bucket" , "two" , "" ) . Return ( twoMetadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "bucket" , "two" , "" , "" , mock . Anything ) . Return ( twoMetadata . Md5 , nil ) . Once ( )
request , err = http . NewRequest ( "PUT" , testServer . URL + "/bucket/two" , bytes . NewBufferString ( "hello world" ) )
delete ( request . Header , "Content-Type" )
request . Header . Add ( "Content-Type" , "application/json" )
@ -1024,13 +1009,11 @@ func (s *MySuite) TestPartialContent(c *C) {
}
typedDriver . On ( "CreateBucket" , "foo" , "private" ) . Return ( nil ) . Once ( )
typedDriver . On ( "CreateObject" , "foo" , "bar" , "" , "" , mock . Anything ) . Return ( nil ) . Once ( )
typedDriver . On ( "GetObjectMetadata" , "foo" , "bar" , "" ) . Return ( metadata , nil ) . Once ( )
typedDriver . On ( "CreateObject" , "foo" , "bar" , "" , "" , mock . Anything ) . Return ( metadata . Md5 , nil ) . Once ( )
err := driver . CreateBucket ( "foo" , "private" )
c . Assert ( err , IsNil )
driver . CreateObject ( "foo" , "bar" , "" , "" , bytes . NewBufferString ( "hello world" ) )
driver . GetObjectMetadata ( "foo" , "bar" , "" )
// prepare for GET on range request
typedDriver . SetGetObjectWriter ( "foo" , "bar" , [ ] byte ( "hello world" ) )