From 211ef70279d9dc59c77b22a1d2f470f81dd68cac Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 20 Feb 2023 12:06:09 +0200 Subject: [PATCH] native timeouts try --- .../e2e/Services/Databases/DatabasesBase.php | 77 ++++++------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 1953048959..310fcc4034 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -182,6 +182,18 @@ trait DatabasesBase 'key' => 'birthDay', 'required' => false, ]); + + $longtext = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/attributes/string', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'key' => 'longtext', + 'size' => 100000000, + 'required' => false, + 'default' => null, + ]); + $this->assertEquals(202, $title['headers']['status-code']); $this->assertEquals($title['body']['key'], 'title'); $this->assertEquals($title['body']['type'], 'string'); @@ -210,6 +222,12 @@ trait DatabasesBase $this->assertEquals($datetime['body']['type'], 'datetime'); $this->assertEquals($datetime['body']['required'], false); + $this->assertEquals($longtext['headers']['status-code'], 202); + $this->assertEquals($longtext['body']['key'], 'longtext'); + $this->assertEquals($longtext['body']['type'], 'string'); + $this->assertEquals($longtext['body']['required'], false); + + // wait for database worker to create attributes sleep(2); @@ -220,12 +238,13 @@ trait DatabasesBase ]), []); $this->assertIsArray($movies['body']['attributes']); - $this->assertCount(5, $movies['body']['attributes']); + $this->assertCount(6, $movies['body']['attributes']); $this->assertEquals($movies['body']['attributes'][0]['key'], $title['body']['key']); $this->assertEquals($movies['body']['attributes'][1]['key'], $releaseYear['body']['key']); $this->assertEquals($movies['body']['attributes'][2]['key'], $duration['body']['key']); $this->assertEquals($movies['body']['attributes'][3]['key'], $actors['body']['key']); $this->assertEquals($movies['body']['attributes'][4]['key'], $datetime['body']['key']); + $this->assertEquals($movies['body']['attributes'][5]['key'], $longtext['body']['key']); return $data; } @@ -350,17 +369,6 @@ trait DatabasesBase 'default' => null, ]); - $longtext = $this->client->call(Client::METHOD_POST, $attributesPath . '/string', array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]), [ - 'key' => 'longtext', - 'size' => 100000000, - 'required' => false, - 'default' => null, - ]); - $this->assertEquals(202, $string['headers']['status-code']); $this->assertEquals('string', $string['body']['key']); $this->assertEquals('string', $string['body']['type']); @@ -435,15 +443,8 @@ trait DatabasesBase $this->assertEquals(false, $datetime['body']['array']); $this->assertEquals(null, $datetime['body']['default']); - $this->assertEquals(202, $longtext['headers']['status-code']); - $this->assertEquals('longtext', $longtext['body']['key']); - $this->assertEquals('string', $longtext['body']['type']); - $this->assertEquals(false, $longtext['body']['required']); - $this->assertEquals(false, $longtext['body']['array']); - $this->assertEquals(null, $longtext['body']['default']); - // wait for database worker to create attributes - sleep(33); + sleep(30); $stringResponse = $this->client->call(Client::METHOD_GET, $attributesPath . '/' . $string['body']['key'], array_merge([ 'content-type' => 'application/json', @@ -499,12 +500,6 @@ trait DatabasesBase 'x-appwrite-key' => $this->getProject()['apiKey'] ])); - $longtextResponse = $this->client->call(Client::METHOD_GET, $attributesPath . '/' . $longtext['body']['key'], array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ])); - $this->assertEquals(200, $stringResponse['headers']['status-code']); $this->assertEquals($string['body']['key'], $stringResponse['body']['key']); $this->assertEquals($string['body']['type'], $stringResponse['body']['type']); @@ -587,15 +582,6 @@ trait DatabasesBase $this->assertEquals($datetime['body']['array'], $datetimeResponse['body']['array']); $this->assertEquals($datetime['body']['default'], $datetimeResponse['body']['default']); - $this->assertEquals(200, $longtextResponse['headers']['status-code']); - $this->assertEquals($longtext['body']['key'], $longtextResponse['body']['key']); - $this->assertEquals($longtext['body']['type'], $longtextResponse['body']['type']); - $this->assertEquals('available', $longtextResponse['body']['status']); - $this->assertEquals($longtext['body']['required'], $longtextResponse['body']['required']); - $this->assertEquals($longtext['body']['array'], $longtextResponse['body']['array']); - $this->assertEquals($longtext['body']['default'], $longtextResponse['body']['default']); - - $attributes = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -603,12 +589,12 @@ trait DatabasesBase ])); $this->assertEquals(200, $attributes['headers']['status-code']); - $this->assertEquals(10, $attributes['body']['total']); + $this->assertEquals(9, $attributes['body']['total']); $attributes = $attributes['body']['attributes']; $this->assertIsArray($attributes); - $this->assertCount(10, $attributes); + $this->assertCount(9, $attributes); $this->assertEquals($stringResponse['body']['key'], $attributes[0]['key']); $this->assertEquals($stringResponse['body']['type'], $attributes[0]['type']); @@ -683,14 +669,6 @@ trait DatabasesBase $this->assertEquals($datetimeResponse['body']['array'], $attributes[8]['array']); $this->assertEquals($datetimeResponse['body']['default'], $attributes[8]['default']); - $this->assertEquals($longtextResponse['body']['key'], $attributes[9]['key']); - $this->assertEquals($longtextResponse['body']['type'], $attributes[9]['type']); - $this->assertEquals($longtextResponse['body']['status'], $attributes[9]['status']); - $this->assertEquals($longtextResponse['body']['required'], $attributes[9]['required']); - $this->assertEquals($longtextResponse['body']['array'], $attributes[9]['array']); - $this->assertEquals($longtextResponse['body']['default'], $attributes[9]['default']); - - $collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -702,7 +680,7 @@ trait DatabasesBase $attributes = $collection['body']['attributes']; $this->assertIsArray($attributes); - $this->assertCount(10, $attributes); + $this->assertCount(9, $attributes); $this->assertEquals($stringResponse['body']['key'], $attributes[0]['key']); $this->assertEquals($stringResponse['body']['type'], $attributes[0]['type']); @@ -777,13 +755,6 @@ trait DatabasesBase $this->assertEquals($datetimeResponse['body']['array'], $attributes[8]['array']); $this->assertEquals($datetimeResponse['body']['default'], $attributes[8]['default']); - $this->assertEquals($longtextResponse['body']['key'], $attributes[9]['key']); - $this->assertEquals($longtextResponse['body']['type'], $attributes[9]['type']); - $this->assertEquals($longtextResponse['body']['status'], $attributes[9]['status']); - $this->assertEquals($longtextResponse['body']['required'], $attributes[9]['required']); - $this->assertEquals($longtextResponse['body']['array'], $attributes[9]['array']); - $this->assertEquals($longtextResponse['body']['default'], $attributes[9]['default']); - /** * Test for FAILURE */