2020-01-13 10:28:26 +13:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\E2E\Services\Storage;
|
|
|
|
|
2021-08-29 20:19:25 +12:00
|
|
|
use Tests\E2E\Client;
|
2020-01-13 10:28:26 +13:00
|
|
|
use Tests\E2E\Scopes\Scope;
|
2021-08-29 20:19:25 +12:00
|
|
|
use Tests\E2E\Scopes\ProjectCustom;
|
|
|
|
use Tests\E2E\Scopes\SideConsole;
|
2020-01-13 10:28:26 +13:00
|
|
|
|
|
|
|
class StorageConsoleClientTest extends Scope
|
|
|
|
{
|
2021-08-29 20:19:25 +12:00
|
|
|
use SideConsole;
|
2020-01-13 10:28:26 +13:00
|
|
|
use StorageBase;
|
2021-08-29 20:19:25 +12:00
|
|
|
use ProjectCustom;
|
|
|
|
|
|
|
|
public function testGetStorageUsage()
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/storage/usage', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id']
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'range' => '32h'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals($response['headers']['status-code'], 400);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/storage/usage', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id']
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'range' => '24h'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals($response['headers']['status-code'], 200);
|
|
|
|
$this->assertEquals(count($response['body']), 3);
|
|
|
|
$this->assertEquals($response['body']['range'], '24h');
|
|
|
|
$this->assertIsArray($response['body']['storage']);
|
|
|
|
$this->assertIsArray($response['body']['files']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetStorageBucketUsage()
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
|
|
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/storage/default/usage', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id']
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'range' => '32h'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals($response['headers']['status-code'], 400);
|
|
|
|
|
|
|
|
// TODO: Uncomment once we implement check for missing bucketId in the usage endpoint.
|
|
|
|
|
|
|
|
// $response = $this->client->call(Client::METHOD_GET, '/storage/randomBucketId/usage', array_merge([
|
|
|
|
// 'content-type' => 'application/json',
|
|
|
|
// 'x-appwrite-project' => $this->getProject()['$id']
|
|
|
|
// ], $this->getHeaders()), [
|
|
|
|
// 'range' => '24h'
|
|
|
|
// ]);
|
|
|
|
|
|
|
|
// $this->assertEquals($response['headers']['status-code'], 404);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/storage/default/usage', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id']
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'range' => '24h'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals($response['headers']['status-code'], 200);
|
2021-08-29 20:54:50 +12:00
|
|
|
$this->assertEquals(count($response['body']), 6);
|
2021-08-29 20:19:25 +12:00
|
|
|
$this->assertEquals($response['body']['range'], '24h');
|
2021-08-29 20:54:50 +12:00
|
|
|
$this->assertIsArray($response['body']['files.count']);
|
2021-08-29 20:19:25 +12:00
|
|
|
$this->assertIsArray($response['body']['files.create']);
|
|
|
|
$this->assertIsArray($response['body']['files.read']);
|
|
|
|
$this->assertIsArray($response['body']['files.update']);
|
|
|
|
$this->assertIsArray($response['body']['files.delete']);
|
|
|
|
}
|
2020-01-13 10:28:26 +13:00
|
|
|
}
|