From 8d1c57d0e73170fc725ab42c5b599d9e3c26e58f Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 7 Jul 2026 15:36:56 +0530 Subject: [PATCH] added tests --- .../e2e/Services/Databases/DatabasesBase.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index e3efe3bbd9..4beed77479 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -776,6 +776,45 @@ trait DatabasesBase $this->assertEquals($this->getDatabaseType(), $database['body']['type']); } + public function testDatabaseStatus(): void + { + if ($this->getSide() === 'client') { + // Databases are created and read with a server API key. + $this->expectNotToPerformAssertions(); + return; + } + + $headers = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]; + + /** + * Test for SUCCESS + * A newly created database defaults to the "ready" status. + */ + $database = $this->client->call(Client::METHOD_POST, $this->getApiBasePath(), $headers, [ + 'databaseId' => ID::unique(), + 'name' => 'Status Database', + ]); + + $this->assertEquals(201, $database['headers']['status-code']); + $this->assertArrayHasKey('status', $database['body']); + $this->assertEquals('ready', $database['body']['status']); + + $databaseId = $database['body']['$id']; + + /** + * The status is persisted and returned on read. + */ + $response = $this->client->call(Client::METHOD_GET, $this->getApiBasePath() . '/' . $databaseId, $headers); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertArrayHasKey('status', $response['body']); + $this->assertEquals('ready', $response['body']['status']); + } + public function testCreateCollection(): void { $data = $this->setupDatabase();