Skip to content

Commit

Permalink
Rollback failed transactions in TestCase.php to not break followup tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Jan 8, 2021
1 parent dc00c8a commit f0c6cfd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/lib/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ public static function tearDownAfterClass(): void {
}
$dataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest');
if (self::$wasDatabaseAllowed && \OC::$server->getDatabaseConnection()) {
$queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$db = \OC::$server->getDatabaseConnection();
if ($db->inTransaction()) {
$db->rollBack();
throw new \Exception('There was a transaction still in progress and needed to be rolled back. Please fix this in your test.');
}
$queryBuilder = $db->getQueryBuilder();

self::tearDownAfterClassCleanShares($queryBuilder);
self::tearDownAfterClassCleanStorages($queryBuilder);
Expand Down

0 comments on commit f0c6cfd

Please sign in to comment.