From 7a36e9262a0b64474732e7506cd6a9ba98968d3e Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Fri, 1 May 2020 13:43:31 +0300 Subject: [PATCH] Fixed tests --- tests/e2e/Services/Health/HealthBase.php | 230 +---------------- .../Health/HealthCustomClientTest.php | 231 ++++++++++++++++++ 2 files changed, 232 insertions(+), 229 deletions(-) diff --git a/tests/e2e/Services/Health/HealthBase.php b/tests/e2e/Services/Health/HealthBase.php index 9a14fbfc2..ff9aab9f8 100644 --- a/tests/e2e/Services/Health/HealthBase.php +++ b/tests/e2e/Services/Health/HealthBase.php @@ -6,233 +6,5 @@ use Tests\E2E\Client; trait HealthBase { - public function testHTTPSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('OK', $response['body']['status']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testDBSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('OK', $response['body']['status']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testCacheSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('OK', $response['body']['status']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testTimeSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/time', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertIsInt($response['body']['remote']); - $this->assertIsInt($response['body']['local']); - $this->assertNotEmpty($response['body']['remote']); - $this->assertNotEmpty($response['body']['local']); - $this->assertLessThan(10, $response['body']['diff']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testWebhooksSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/queue/webhooks', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertIsInt($response['body']['size']); - $this->assertLessThan(50, $response['body']['size']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testTasksSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/queue/tasks', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertIsInt($response['body']['size']); - $this->assertLessThan(50, $response['body']['size']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testLogsSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/queue/logs', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertIsInt($response['body']['size']); - $this->assertLessThan(50, $response['body']['size']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testUsageSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/queue/usage', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertIsInt($response['body']['size']); - $this->assertLessThan(50, $response['body']['size']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testCertificatesSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/queue/certificates', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertIsInt($response['body']['size']); - $this->assertLessThan(50, $response['body']['size']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testStorageLocalSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/storage/local', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('OK', $response['body']['status']); - - /** - * Test for FAILURE - */ - - return []; - } - - public function testStorageAntiVirusSuccess():array - { - /** - * Test for SUCCESS - */ - $response = $this->client->call(Client::METHOD_GET, '/health/storage/anti-virus', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), []); - - $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('online', $response['body']['status']); - $this->assertStringStartsWith('ClamAV ', $response['body']['version']); - - /** - * Test for FAILURE - */ - - return []; - } + } \ No newline at end of file diff --git a/tests/e2e/Services/Health/HealthCustomClientTest.php b/tests/e2e/Services/Health/HealthCustomClientTest.php index dd0222800..5fe1c811c 100644 --- a/tests/e2e/Services/Health/HealthCustomClientTest.php +++ b/tests/e2e/Services/Health/HealthCustomClientTest.php @@ -2,6 +2,7 @@ namespace Tests\E2E\Services\Health; +use Tests\E2E\Client; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\SideClient; @@ -11,4 +12,234 @@ class HealthCustomClientTest extends Scope use HealthBase; use ProjectCustom; use SideClient; + + public function testHTTPSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals('OK', $response['body']['status']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testDBSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals('OK', $response['body']['status']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testCacheSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals('OK', $response['body']['status']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testTimeSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/time', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['remote']); + $this->assertIsInt($response['body']['local']); + $this->assertNotEmpty($response['body']['remote']); + $this->assertNotEmpty($response['body']['local']); + $this->assertLessThan(10, $response['body']['diff']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testWebhooksSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/webhooks', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(50, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testTasksSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/tasks', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(50, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testLogsSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/logs', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(50, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testUsageSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/usage', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(50, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testCertificatesSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/queue/certificates', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertIsInt($response['body']['size']); + $this->assertLessThan(50, $response['body']['size']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testStorageLocalSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/storage/local', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals('OK', $response['body']['status']); + + /** + * Test for FAILURE + */ + + return []; + } + + public function testStorageAntiVirusSuccess():array + { + /** + * Test for SUCCESS + */ + $response = $this->client->call(Client::METHOD_GET, '/health/storage/anti-virus', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals('online', $response['body']['status']); + $this->assertStringStartsWith('ClamAV ', $response['body']['version']); + + /** + * Test for FAILURE + */ + + return []; + } } \ No newline at end of file