From 44af531881301035a6f76816289fc0ebc68583fc Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 26 Dec 2022 11:11:13 +0200 Subject: [PATCH] tests adjustments --- .../Databases/DatabasesConsoleClientTest.php | 71 ++++++++----------- .../Functions/FunctionsConsoleClientTest.php | 17 +++-- .../Storage/StorageConsoleClientTest.php | 8 +-- .../Services/Users/UsersConsoleClientTest.php | 67 +++++++---------- 4 files changed, 66 insertions(+), 97 deletions(-) diff --git a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php index 71fa7a590f..cdbeda00b6 100644 --- a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php @@ -56,47 +56,39 @@ class DatabasesConsoleClientTest extends Scope /** * @depends testCreateCollection */ - // public function testGetDatabaseUsage(array $data) - // { - // $databaseId = $data['databaseId']; - // /** - // * Test for FAILURE - // */ + public function testGetDatabaseUsage(array $data) + { + $databaseId = $data['databaseId']; + /** + * Test for FAILURE + */ - // $response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/usage', array_merge([ - // 'content-type' => 'application/json', - // 'x-appwrite-project' => $this->getProject()['$id'] - // ], $this->getHeaders()), [ - // 'range' => '32h' - // ]); + $response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/usage', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()), [ + 'range' => '32h' + ]); - // $this->assertEquals(400, $response['headers']['status-code']); + $this->assertEquals(400, $response['headers']['status-code']); - // /** - // * Test for SUCCESS - // */ + /** + * Test for SUCCESS + */ - // $response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/usage', array_merge([ - // 'content-type' => 'application/json', - // 'x-appwrite-project' => $this->getProject()['$id'] - // ], $this->getHeaders()), [ - // 'range' => '24h' - // ]); + $response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/usage', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()), [ + 'range' => '24h' + ]); - // $this->assertEquals(200, $response['headers']['status-code']); - // $this->assertEquals(count($response['body']), 11); - // $this->assertEquals($response['body']['range'], '24h'); - // $this->assertIsArray($response['body']['documentsCount']); - // $this->assertIsArray($response['body']['collectionsCount']); - // $this->assertIsArray($response['body']['documentsCreate']); - // $this->assertIsArray($response['body']['documentsRead']); - // $this->assertIsArray($response['body']['documentsUpdate']); - // $this->assertIsArray($response['body']['documentsDelete']); - // $this->assertIsArray($response['body']['collectionsCreate']); - // $this->assertIsArray($response['body']['collectionsRead']); - // $this->assertIsArray($response['body']['collectionsUpdate']); - // $this->assertIsArray($response['body']['collectionsDelete']); - // } + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals(count($response['body']), 3); + $this->assertEquals($response['body']['range'], '24h'); + $this->assertIsArray($response['body']['documentsCount']); + $this->assertIsArray($response['body']['collectionsCount']); + } /** @@ -136,15 +128,10 @@ class DatabasesConsoleClientTest extends Scope ], $this->getHeaders()), [ 'range' => '24h' ]); - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(count($response['body']), 6); + $this->assertEquals(count($response['body']), 2); $this->assertEquals($response['body']['range'], '24h'); $this->assertIsArray($response['body']['documentsCount']); - $this->assertIsArray($response['body']['documentsCreate']); - $this->assertIsArray($response['body']['documentsRead']); - $this->assertIsArray($response['body']['documentsUpdate']); - $this->assertIsArray($response['body']['documentsDelete']); } /** diff --git a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php index 68b9ac46ea..9cba3719cb 100644 --- a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php @@ -90,16 +90,15 @@ class FunctionsConsoleClientTest extends Scope ]); $this->assertEquals($response['headers']['status-code'], 200); - $this->assertEquals(count($response['body']), 9); + $this->assertEquals(count($response['body']), 8); $this->assertEquals($response['body']['range'], '24h'); - $this->assertIsArray($response['body']['executionsTotal']); - $this->assertIsArray($response['body']['executionsFailure']); - $this->assertIsArray($response['body']['executionsSuccess']); - $this->assertIsArray($response['body']['executionsTime']); - $this->assertIsArray($response['body']['buildsTotal']); - $this->assertIsArray($response['body']['buildsFailure']); - $this->assertIsArray($response['body']['buildsSuccess']); - $this->assertIsArray($response['body']['buildsTime']); + $this->assertIsArray($response['body']['deployments']); + $this->assertIsArray($response['body']['deploymentsStorage']); + $this->assertIsArray($response['body']['builds']); + $this->assertIsArray($response['body']['buildsStorage']); + $this->assertIsArray($response['body']['buildsCompute']); + $this->assertIsArray($response['body']['executions']); + $this->assertIsArray($response['body']['executionsCompute']); } /** diff --git a/tests/e2e/Services/Storage/StorageConsoleClientTest.php b/tests/e2e/Services/Storage/StorageConsoleClientTest.php index 8b4aaa1fca..24f40f50e3 100644 --- a/tests/e2e/Services/Storage/StorageConsoleClientTest.php +++ b/tests/e2e/Services/Storage/StorageConsoleClientTest.php @@ -39,7 +39,7 @@ class StorageConsoleClientTest extends Scope ]); $this->assertEquals($response['headers']['status-code'], 200); - $this->assertEquals(12, count($response['body'])); + $this->assertEquals(3, count($response['body'])); $this->assertEquals($response['body']['range'], '24h'); $this->assertIsArray($response['body']['storage']); $this->assertIsArray($response['body']['filesCount']); @@ -94,13 +94,9 @@ class StorageConsoleClientTest extends Scope ]); $this->assertEquals($response['headers']['status-code'], 200); - $this->assertEquals(count($response['body']), 7); + $this->assertEquals(count($response['body']), 2); $this->assertEquals($response['body']['range'], '24h'); $this->assertIsArray($response['body']['filesCount']); - $this->assertIsArray($response['body']['filesCreate']); - $this->assertIsArray($response['body']['filesRead']); - $this->assertIsArray($response['body']['filesUpdate']); - $this->assertIsArray($response['body']['filesDelete']); $this->assertIsArray($response['body']['filesStorage']); } } diff --git a/tests/e2e/Services/Users/UsersConsoleClientTest.php b/tests/e2e/Services/Users/UsersConsoleClientTest.php index 9cc23e825a..6c42a11012 100644 --- a/tests/e2e/Services/Users/UsersConsoleClientTest.php +++ b/tests/e2e/Services/Users/UsersConsoleClientTest.php @@ -23,43 +23,36 @@ class UsersConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'] ], $this->getHeaders()), [ 'range' => '32h', - 'provider' => 'email' ]); $this->assertEquals($response['headers']['status-code'], 400); +// +// $response = $this->client->call(Client::METHOD_GET, '/users/usage', array_merge([ +// 'content-type' => 'application/json', +// 'x-appwrite-project' => $this->getProject()['$id'] +// ], $this->getHeaders()), [ +// 'range' => '24h', +// 'provider' => 'some-random-provider' +// ]); +// +// $this->assertEquals($response['headers']['status-code'], 400); - $response = $this->client->call(Client::METHOD_GET, '/users/usage', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'] - ], $this->getHeaders()), [ - 'range' => '24h', - 'provider' => 'some-random-provider' - ]); +// /** +// * Test for SUCCESS +// */ +// $response = $this->client->call(Client::METHOD_GET, '/users/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']), 2); +// $this->assertEquals($response['body']['range'], '24h'); +// $this->assertIsArray($response['body']['usersCount']); +// $this->assertIsArray($response['body']['sessionsCount']); - $this->assertEquals($response['headers']['status-code'], 400); - - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/users/usage', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'] - ], $this->getHeaders()), [ - 'range' => '24h', - 'provider' => 'email' - ]); - - $this->assertEquals($response['headers']['status-code'], 200); - $this->assertEquals(count($response['body']), 9); - $this->assertEquals($response['body']['range'], '24h'); - $this->assertIsArray($response['body']['usersCount']); - $this->assertIsArray($response['body']['usersCreate']); - $this->assertIsArray($response['body']['usersRead']); - $this->assertIsArray($response['body']['usersUpdate']); - $this->assertIsArray($response['body']['usersDelete']); - $this->assertIsArray($response['body']['sessionsCreate']); - $this->assertIsArray($response['body']['sessionsProviderCreate']); - $this->assertIsArray($response['body']['sessionsDelete']); $response = $this->client->call(Client::METHOD_GET, '/users/usage', array_merge([ 'content-type' => 'application/json', @@ -69,15 +62,9 @@ class UsersConsoleClientTest extends Scope ]); $this->assertEquals($response['headers']['status-code'], 200); - $this->assertEquals(count($response['body']), 9); + $this->assertEquals(count($response['body']), 2); $this->assertEquals($response['body']['range'], '24h'); $this->assertIsArray($response['body']['usersCount']); - $this->assertIsArray($response['body']['usersCreate']); - $this->assertIsArray($response['body']['usersRead']); - $this->assertIsArray($response['body']['usersUpdate']); - $this->assertIsArray($response['body']['usersDelete']); - $this->assertIsArray($response['body']['sessionsCreate']); - $this->assertIsArray($response['body']['sessionsProviderCreate']); - $this->assertIsArray($response['body']['sessionsDelete']); + $this->assertIsArray($response['body']['sessionsCount']); } }