Fix tests

This commit is contained in:
Jake Barnby 2025-10-03 18:56:05 +13:00
parent 59ae403391
commit 2bc90db1f6
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 9 additions and 5 deletions

View file

@ -574,25 +574,25 @@ class TransactionState
} }
break; break;
case Query::TYPE_GREATER_THAN: case Query::TYPE_GREATER:
if (!($docValue > $values[0])) { if (!($docValue > $values[0])) {
return false; return false;
} }
break; break;
case Query::TYPE_GREATER_THAN_EQUAL: case Query::TYPE_GREATER_EQUAL:
if (!($docValue >= $values[0])) { if (!($docValue >= $values[0])) {
return false; return false;
} }
break; break;
case Query::TYPE_LESSER_THAN: case Query::TYPE_LESSER:
if (!($docValue < $values[0])) { if (!($docValue < $values[0])) {
return false; return false;
} }
break; break;
case Query::TYPE_LESSER_THAN_EQUAL: case Query::TYPE_LESSER_EQUAL:
if (!($docValue <= $values[0])) { if (!($docValue <= $values[0])) {
return false; return false;
} }

View file

@ -64,6 +64,10 @@ class Create extends Action
public function action(string $transactionId, array $operations, UtopiaResponse $response, Database $dbForProject, array $plan): void public function action(string $transactionId, array $operations, UtopiaResponse $response, Database $dbForProject, array $plan): void
{ {
if (empty($operations)) {
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Operations array cannot be empty');
}
$transaction = $dbForProject->getDocument('transactions', $transactionId); $transaction = $dbForProject->getDocument('transactions', $transactionId);
if ($transaction->isEmpty() || $transaction->getAttribute('status', '') !== 'pending') { if ($transaction->isEmpty() || $transaction->getAttribute('status', '') !== 'pending') {
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or nonpending transaction'); throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or nonpending transaction');

View file

@ -129,7 +129,7 @@ class Update extends Action
$totalOperations = 0; $totalOperations = 0;
$databaseOperations = []; $databaseOperations = [];
$dbForProject->withTransaction(function () use ($dbForProject, $queueForDeletes, $transactionId, &$transaction, &$operations, &$totalOperations, &$databaseOperations, $queueForEvents, $queueForStatsUsage, $queueForRealtime, $queueForFunctions, $queueForWebhooks) { $dbForProject->withTransaction(function () use ($dbForProject, $transactionState, $queueForDeletes, $transactionId, &$transaction, &$operations, &$totalOperations, &$databaseOperations, $queueForEvents, $queueForStatsUsage, $queueForRealtime, $queueForFunctions, $queueForWebhooks) {
$dbForProject->updateDocument('transactions', $transactionId, new Document([ $dbForProject->updateDocument('transactions', $transactionId, new Document([
'status' => 'committing', 'status' => 'committing',
])); ]));