mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Refactor MongoTest to ensure collection cleanup with try-finally block
This commit modifies the MongoTest class to wrap the collection drop operation in a try-finally block, ensuring that the collection is always dropped after the test execution, even if an exception occurs during the test. This enhances the reliability of the test environment.
This commit is contained in:
1 parent
eebbd5bef4
commit
a582d06621
1 file changed
+4
-3
+4
-3
@@ -266,7 +266,7 @@ class MongoTest extends TestCase
|
||||
{
|
||||
$collectionName = 'count_test';
|
||||
$this->getDatabase()->createCollection($collectionName);
|
||||
|
||||
try {
|
||||
$documents = [];
|
||||
for ($i = 1; $i <= 30; $i++) {
|
||||
$documents[] = [
|
||||
@@ -347,7 +347,8 @@ class MongoTest extends TestCase
|
||||
]);
|
||||
self::assertEquals(6, $complexOrAggregationResult->cursor->firstBatch[0]->total);
|
||||
|
||||
|
||||
$this->getDatabase()->dropCollection($collectionName);
|
||||
} finally {
|
||||
$this->getDatabase()->dropCollection($collectionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user