Add tests for multipart upload

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2017-09-21 14:47:14 +02:00
parent 6fee4232ee
commit 239f561ab2
No known key found for this signature in database
GPG Key ID: CBCA68FBAEBF98C9
2 changed files with 19 additions and 6 deletions

View File

@ -74,7 +74,7 @@ trait S3ObjectTrait {
}
private function singlePartUpload($urn, $stream) {
protected function singlePartUpload($urn, $stream) {
$this->getConnection()->putObject([
'Bucket' => $this->bucket,
'Key' => $urn,
@ -82,7 +82,7 @@ trait S3ObjectTrait {
]);
}
private function multiPartUpload($urn, $stream) {
protected function multiPartUpload($urn, $stream) {
$uploader = new MultipartUploader($this->getConnection(), $stream, [
'bucket' => $this->bucket,
'key' => $urn,

View File

@ -23,19 +23,32 @@ namespace Test\Files\ObjectStore;
use OC\Files\ObjectStore\S3;
class MultiPartUploadS3 extends S3 {
public function multiPartUpload($urn, $stream) {
parent::multiPartUpload($urn, $stream);
}
}
/**
* @group PRIMARY-s3
*/
class S3Test extends ObjectStoreTest {
/**
* @return \OCP\Files\ObjectStore\IObjectStore
*/
protected function getInstance() {
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
if (!is_array($config) || $config['class'] !== 'OC\\Files\\ObjectStore\\S3') {
$this->markTestSkipped('objectstore not configured for s3');
}
return new S3($config['arguments']);
return new MultiPartUploadS3($config['arguments']);
}
public function testMultiPartUploader() {
$s3 = $this->getInstance();
$s3->multiPartUpload('multiparttest', fopen(__FILE__, 'r'));
$result = $s3->readObject('multiparttest');
$this->assertEquals(file_get_contents(__FILE__), stream_get_contents($result));
}
}