From 27d1405af0791c8e74b985403bab16bdbcaa7021 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 23 Nov 2021 12:39:01 -0500 Subject: [PATCH] Test for purged document cache on deleteAttribute --- .../Database/DatabaseCustomServerTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index fba1b09c16..9f8c7130e4 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -193,6 +193,22 @@ class DatabaseCustomServerTest extends Scope // Wait for database worker to finish creating attributes sleep(2); + // Creating document to ensure cache is purged on schema change + $document = $this->client->call(Client::METHOD_POST, '/database/collections/' . $actors['body']['$id'] . '/documents', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'documentId' => 'unique()', + 'data' => [ + 'firstName' => 'lorem', + 'lastName' => 'ipsum', + 'unneeded' => 'dolor' + ], + 'read' => ['role:all'], + 'write' => ['role:all'], + ]); + $index = $this->client->call(Client::METHOD_POST, '/database/collections/' . $actors['body']['$id'] . '/indexes', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -236,6 +252,15 @@ class DatabaseCustomServerTest extends Scope sleep(2); + // Check document to ensure cache is purged on schema change + $document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $actors['body']['$id'] . '/documents/' . $document['body']['$id'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ])); + + $this->assertNotContains($unneededId, $document['body']); + $collection = $this->client->call(Client::METHOD_GET, '/database/collections/' . $actors['body']['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'],