Skip to content

Commit efc21d3

Browse files
committed
Fix tests
1 parent 152882d commit efc21d3

1 file changed

Lines changed: 15 additions & 51 deletions

File tree

tests/e2e/Services/Migrations/MigrationsBase.php

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,21 @@ public function testCreateCsvMigration(): array
11411141
$this->assertEquals(100, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']);
11421142
}, 10_000, 500);
11431143

1144+
// get documents count
1145+
$documents = $this->client->call(Client::METHOD_GET, '/databases/'.$databaseId.'/collections/'.$collectionId.'/documents', array_merge([
1146+
'content-type' => 'application/json',
1147+
'x-appwrite-project' => $this->getProject()['$id'],
1148+
], $this->getHeaders()), [
1149+
'queries' => [
1150+
Query::limit(150)->toString()
1151+
]
1152+
]);
1153+
1154+
$this->assertEquals(200, $documents['headers']['status-code']);
1155+
$this->assertIsArray($documents['body']['documents']);
1156+
$this->assertIsNumeric($documents['body']['total']);
1157+
$this->assertEquals(100, $documents['body']['total']);
1158+
11441159
// all data exists and includes internals, pass.
11451160
$migration = $this->performCsvMigration(
11461161
[
@@ -1167,57 +1182,6 @@ public function testCreateCsvMigration(): array
11671182
$this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']);
11681183
$this->assertEquals(25, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']);
11691184
}, 10_000, 500);
1170-
1171-
return [
1172-
'databaseId' => $databaseId,
1173-
'collectionId' => $collectionId,
1174-
'migrationId' => $migration['body']['$id'],
1175-
];
1176-
}
1177-
1178-
/**
1179-
* @depends testCreateCsvMigration
1180-
*/
1181-
public function testImportSuccessful(array $response): void
1182-
{
1183-
$databaseId = $response['databaseId'];
1184-
$collectionId = $response['collectionId'];
1185-
$migrationId = $response['migrationId'];
1186-
1187-
$documentsCountInCSV = 100;
1188-
1189-
// get migration stats
1190-
$this->assertEventually(function () use ($migrationId, $databaseId, $collectionId, $documentsCountInCSV) {
1191-
$migration = $this->client->call(Client::METHOD_GET, '/migrations/'.$migrationId, array_merge([
1192-
'content-type' => 'application/json',
1193-
'x-appwrite-project' => $this->getProject()['$id'],
1194-
], $this->getHeaders()));
1195-
1196-
$this->assertEquals(200, $migration['headers']['status-code']);
1197-
$this->assertEquals('finished', $migration['body']['stage']);
1198-
$this->assertEquals('completed', $migration['body']['status']);
1199-
$this->assertEquals('CSV', $migration['body']['source']);
1200-
$this->assertEquals('Appwrite', $migration['body']['destination']);
1201-
$this->assertContains(Resource::TYPE_DOCUMENT, $migration['body']['resources']);
1202-
$this->assertArrayHasKey(Resource::TYPE_DOCUMENT, $migration['body']['statusCounters']);
1203-
$this->assertEquals($documentsCountInCSV, $migration['body']['statusCounters'][Resource::TYPE_DOCUMENT]['success']);
1204-
}, 60000, 500);
1205-
1206-
// get documents count
1207-
$documents = $this->client->call(Client::METHOD_GET, '/databases/'.$databaseId.'/collections/'.$collectionId.'/documents', array_merge([
1208-
'content-type' => 'application/json',
1209-
'x-appwrite-project' => $this->getProject()['$id'],
1210-
], $this->getHeaders()), [
1211-
'queries' => [
1212-
// there should be only 100!
1213-
Query::limit(150)->toString()
1214-
]
1215-
]);
1216-
1217-
$this->assertEquals(200, $documents['headers']['status-code']);
1218-
$this->assertIsArray($documents['body']['documents']);
1219-
$this->assertIsNumeric($documents['body']['total']);
1220-
$this->assertEquals($documentsCountInCSV, $documents['body']['total']);
12211185
}
12221186

12231187
private function performCsvMigration(array $body): array

0 commit comments

Comments
 (0)