1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00

Ensure attributes are removed from queue before adding documents

This commit is contained in:
kodumbeats 2021-06-18 13:09:07 -04:00
parent afd347ca6f
commit 4567bc0d77
2 changed files with 28 additions and 0 deletions

View file

@ -88,6 +88,24 @@ trait DatabaseBase
$this->assertEquals($actors['body']['required'], false);
$this->assertEquals($actors['body']['array'], true);
// wait for database worker to create attributes
sleep(5);
$movies = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), []);
$this->assertEquals($movies['body']['$id'], $title['body']['$collection']);
$this->assertEquals($movies['body']['$id'], $releaseYear['body']['$collection']);
$this->assertEquals($movies['body']['$id'], $actors['body']['$collection']);
$this->assertIsArray($movies['body']['attributes']);
$this->assertCount(3, $movies['body']['attributes']);
$this->assertEquals($movies['body']['attributes'][0]['$id'], $title['body']['$id']);
$this->assertEquals($movies['body']['attributes'][1]['$id'], $releaseYear['body']['$id']);
$this->assertEquals($movies['body']['attributes'][2]['$id'], $actors['body']['$id']);
return $data;
}

View file

@ -55,12 +55,22 @@ class DatabaseCustomServerTest extends Scope
'required' => true,
]);
// wait for database worker to finish creating attributes
sleep(5);
$collection = $this->client->call(Client::METHOD_GET, '/database/collections/' . $actors['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), []);
$this->assertEquals($collection['body']['$id'], $firstName['body']['$collection']);
$this->assertEquals($collection['body']['$id'], $lastName['body']['$collection']);
$this->assertIsArray($collection['body']['attributes']);
$this->assertCount(2, $collection['body']['attributes']);
$this->assertEquals($collection['body']['attributes'][0]['$id'], $firstName['body']['$id']);
$this->assertEquals($collection['body']['attributes'][1]['$id'], $lastName['body']['$id']);
// Add Documents to the collection
$document1 = $this->client->call(Client::METHOD_POST, '/database/collections/' . $actors['body']['$id'] . '/documents', array_merge([
'content-type' => 'application/json',