From 0d2bbb0ae97f52fbd770797aa224e5e7547e659d Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 24 Aug 2021 19:35:43 -0400 Subject: [PATCH] Fix tests for index limits --- .../Database/DatabaseCustomServerTest.php | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index a3049fa4bd..e5a75fa685 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -318,6 +318,7 @@ class DatabaseCustomServerTest extends Scope 'name' => 'testLimitException', 'read' => ['role:all'], 'write' => ['role:all'], + 'permission' => 'document', ]); $this->assertEquals($collection['headers']['status-code'], 201); @@ -339,12 +340,9 @@ class DatabaseCustomServerTest extends Scope ]); $this->assertEquals($attribute['headers']['status-code'], 201); - - // sleep(4); - // \usleep(250000); } - sleep(20); + sleep(5); $collection = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collectionId, array_merge([ 'content-type' => 'application/json', @@ -352,16 +350,10 @@ class DatabaseCustomServerTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - var_dump($collection['body']); - $this->assertEquals($collection['headers']['status-code'], 200); $this->assertEquals($collection['body']['name'], 'testLimitException'); $this->assertIsArray($collection['body']['attributes']); $this->assertIsArray($collection['body']['indexes']); - $this->assertIsArray($collection['body']['attributesInQueue']); - $this->assertIsArray($collection['body']['indexesInQueue']); - $this->assertCount(0, $collection['body']['attributesInQueue']); - $this->assertCount(0, $collection['body']['indexesInQueue']); $this->assertCount(64, $collection['body']['attributes']); $this->assertCount(0, $collection['body']['indexes']); @@ -381,13 +373,10 @@ class DatabaseCustomServerTest extends Scope ]); $this->assertEquals(201, $index['headers']['status-code']); - $this->assertEquals("key_attribute{$i}", $index['body']['$id']); - - // sleep(4); - // \usleep(250000); + $this->assertEquals("key_attribute{$i}", $index['body']['key']); } - sleep(20); + sleep(5); $collection = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collectionId, array_merge([ 'content-type' => 'application/json', @@ -395,16 +384,10 @@ class DatabaseCustomServerTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - var_dump($collection); - $this->assertEquals($collection['headers']['status-code'], 200); $this->assertEquals($collection['body']['name'], 'testLimitException'); $this->assertIsArray($collection['body']['attributes']); $this->assertIsArray($collection['body']['indexes']); - $this->assertIsArray($collection['body']['attributesInQueue']); - $this->assertIsArray($collection['body']['indexesInQueue']); - $this->assertCount(0, $collection['body']['attributesInQueue']); - $this->assertCount(0, $collection['body']['indexesInQueue']); $this->assertCount(64, $collection['body']['attributes']); $this->assertCount(61, $collection['body']['indexes']); @@ -413,11 +396,12 @@ class DatabaseCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'] ]), [ - 'id' => 'tooMany', + 'indexId' => 'tooMany', 'type' => 'key', - 'attributes' => ['attribute62'], + 'attributes' => ['attribute61'], ]); $this->assertEquals(400, $tooMany['headers']['status-code']); + $this->assertEquals('Index limit exceeded', $tooMany['body']['message']); } } \ No newline at end of file