mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Fix tests
This commit is contained in:
@@ -1141,6 +1141,21 @@ trait MigrationsBase
|
||||
$this->assertEquals(100, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']);
|
||||
}, 10_000, 500);
|
||||
|
||||
// get documents count
|
||||
$documents = $this->client->call(Client::METHOD_GET, '/databases/'.$databaseId.'/collections/'.$collectionId.'/documents', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::limit(150)->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $documents['headers']['status-code']);
|
||||
$this->assertIsArray($documents['body']['documents']);
|
||||
$this->assertIsNumeric($documents['body']['total']);
|
||||
$this->assertEquals(100, $documents['body']['total']);
|
||||
|
||||
// all data exists and includes internals, pass.
|
||||
$migration = $this->performCsvMigration(
|
||||
[
|
||||
@@ -1167,57 +1182,6 @@ trait MigrationsBase
|
||||
$this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']);
|
||||
$this->assertEquals(25, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']);
|
||||
}, 10_000, 500);
|
||||
|
||||
return [
|
||||
'databaseId' => $databaseId,
|
||||
'collectionId' => $collectionId,
|
||||
'migrationId' => $migration['body']['$id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreateCsvMigration
|
||||
*/
|
||||
public function testImportSuccessful(array $response): void
|
||||
{
|
||||
$databaseId = $response['databaseId'];
|
||||
$collectionId = $response['collectionId'];
|
||||
$migrationId = $response['migrationId'];
|
||||
|
||||
$documentsCountInCSV = 100;
|
||||
|
||||
// get migration stats
|
||||
$this->assertEventually(function () use ($migrationId, $databaseId, $collectionId, $documentsCountInCSV) {
|
||||
$migration = $this->client->call(Client::METHOD_GET, '/migrations/'.$migrationId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $migration['headers']['status-code']);
|
||||
$this->assertEquals('finished', $migration['body']['stage']);
|
||||
$this->assertEquals('completed', $migration['body']['status']);
|
||||
$this->assertEquals('CSV', $migration['body']['source']);
|
||||
$this->assertEquals('Appwrite', $migration['body']['destination']);
|
||||
$this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']);
|
||||
$this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']);
|
||||
$this->assertEquals($documentsCountInCSV, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']);
|
||||
}, 60000, 500);
|
||||
|
||||
// get documents count
|
||||
$documents = $this->client->call(Client::METHOD_GET, '/databases/'.$databaseId.'/collections/'.$collectionId.'/documents', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
// there should be only 100!
|
||||
Query::limit(150)->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $documents['headers']['status-code']);
|
||||
$this->assertIsArray($documents['body']['documents']);
|
||||
$this->assertIsNumeric($documents['body']['total']);
|
||||
$this->assertEquals($documentsCountInCSV, $documents['body']['total']);
|
||||
}
|
||||
|
||||
private function performCsvMigration(array $body): array
|
||||
|
||||
Reference in New Issue
Block a user