@@ -323,6 +323,34 @@ func TestGetObject(t *testing.T) {
323323 ds3Testing .AssertString (t , "Response" , stringResponse , string (bs ))
324324}
325325
326+ func TestGetPartialObject (t * testing.T ) {
327+ stringResponse := "object contents"
328+
329+ // Create and run the mocked client.
330+ requestHeaders := & http.Header {}
331+ requestHeaders .Add ("Range" , "bytes=1-5" )
332+
333+ response , err := mockedClient (t ).
334+ Expecting (HTTP_VERB_GET , "/bucketName/object" , & url.Values {}, requestHeaders , nil ).
335+ Returning (206 , stringResponse , nil ).
336+ GetObject (models .NewGetObjectRequest ("bucketName" , "object" ).WithRange (1 , 5 ))
337+
338+ // Check the error result.
339+ ds3Testing .AssertNilError (t , err )
340+
341+ // Check the response value.
342+ if response == nil {
343+ t .Fatal ("Response was unexpectedly nil." )
344+ }
345+ if response .Content == nil {
346+ t .Fatal ("Response content was unexpectedly nil." )
347+ }
348+ defer response .Content .Close ()
349+ bs , readErr := ioutil .ReadAll (response .Content )
350+ ds3Testing .AssertNilError (t , readErr )
351+ ds3Testing .AssertString (t , "Response" , stringResponse , string (bs ))
352+ }
353+
326354func TestGetObjectRange (t * testing.T ) {
327355 stringResponse := "object contents"
328356 requestHeaders := & http.Header {"Range" : []string {"bytes=20-179" }}
0 commit comments