Add E2E test for platform migration

This commit is contained in:
Prem Palanisamy
2026-03-03 16:21:36 +00:00
parent 01c2d0f04b
commit d51130ec8f
@@ -1170,6 +1170,83 @@ trait MigrationsBase
return new CURLFile($tarPath, 'application/x-gzip', \basename($tarPath));
}
/**
* Integrations
*/
public function testAppwriteMigrationPlatform(): void
{
// Create platform on source project
$response = $this->client->call(Client::METHOD_POST, '/projects/' . $this->getProject()['$id'] . '/platforms', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'type' => 'web',
'name' => 'Test Platform',
'hostname' => 'localhost',
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$platform = $response['body'];
$result = $this->performMigrationSync([
'resources' => [
Resource::TYPE_PLATFORM,
],
'endpoint' => $this->webEndpoint,
'projectId' => $this->getProject()['$id'],
'apiKey' => $this->getProject()['apiKey'],
]);
$this->assertEquals('completed', $result['status']);
$this->assertEquals([Resource::TYPE_PLATFORM], $result['resources']);
$this->assertArrayHasKey(Resource::TYPE_PLATFORM, $result['statusCounters']);
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['error']);
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['pending']);
$this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PLATFORM]['success']);
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['processing']);
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PLATFORM]['warning']);
// Verify platform on destination project
$response = $this->client->call(Client::METHOD_GET, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']);
$this->assertGreaterThan(0, $response['body']['total']);
$foundPlatform = null;
foreach ($response['body']['platforms'] as $p) {
if ($p['name'] === 'Test Platform' && $p['type'] === 'web') {
$foundPlatform = $p;
break;
}
}
$this->assertNotNull($foundPlatform);
$this->assertEquals('web', $foundPlatform['type']);
$this->assertEquals('Test Platform', $foundPlatform['name']);
$this->assertEquals('localhost', $foundPlatform['hostname']);
// Cleanup on destination
$this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getDestinationProject()['$id'] . '/platforms/' . $foundPlatform['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
// Cleanup on source
$this->client->call(Client::METHOD_DELETE, '/projects/' . $this->getProject()['$id'] . '/platforms/' . $platform['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
}
/**
* Import documents from a CSV file.
*/