summaryrefslogtreecommitdiff
path: root/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/core/txns/ensure_active_txn_for_prepare_transaction.js')
-rw-r--r--jstests/core/txns/ensure_active_txn_for_prepare_transaction.js98
1 files changed, 44 insertions, 54 deletions
diff --git a/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js b/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
index a6ef6ab7c77..2847d139c89 100644
--- a/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
+++ b/jstests/core/txns/ensure_active_txn_for_prepare_transaction.js
@@ -5,58 +5,48 @@
*/
(function() {
- "use strict";
- load("jstests/core/txns/libs/prepare_helpers.js");
-
- const dbName = "test";
- const collName = "ensure_active_txn_for_prepare_transaction";
- const testDB = db.getSiblingDB(dbName);
- const testColl = testDB.getCollection(collName);
-
- testDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
- assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}}));
-
- const session = db.getMongo().startSession({causalConsistency: false});
- const sessionDB = session.getDatabase(dbName);
- const sessionColl = sessionDB.getCollection(collName);
-
- jsTestLog("Test that we can't call prepareTransaction if there was never a transaction on " +
- "the session");
- assert.commandFailedWithCode(sessionDB.adminCommand({
- prepareTransaction: 1,
- txnNumber: NumberLong(0),
- stmtId: NumberInt(1),
- autocommit: false
- }),
- ErrorCodes.NoSuchTransaction);
-
- jsTestLog(
- "Test that we can't call prepareTransaction if the most recent transaction was aborted");
- session.startTransaction();
- assert.commandWorked(sessionColl.insert({_id: 1}));
- assert.commandWorked(session.abortTransaction_forTesting());
-
- assert.commandFailedWithCode(sessionDB.adminCommand({
- prepareTransaction: 1,
- txnNumber: NumberLong(0),
- stmtId: NumberInt(1),
- autocommit: false
- }),
- ErrorCodes.NoSuchTransaction);
-
- jsTestLog(
- "Test that we can't call prepareTransaction if the most recent transaction was committed");
- session.startTransaction();
- assert.commandWorked(sessionColl.insert({_id: 1}));
- assert.commandWorked(session.commitTransaction_forTesting());
-
- assert.commandFailedWithCode(sessionDB.adminCommand({
- prepareTransaction: 1,
- txnNumber: NumberLong(1),
- stmtId: NumberInt(1),
- autocommit: false
- }),
- ErrorCodes.TransactionCommitted);
-
- session.endSession();
+"use strict";
+load("jstests/core/txns/libs/prepare_helpers.js");
+
+const dbName = "test";
+const collName = "ensure_active_txn_for_prepare_transaction";
+const testDB = db.getSiblingDB(dbName);
+const testColl = testDB.getCollection(collName);
+
+testDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
+assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}}));
+
+const session = db.getMongo().startSession({causalConsistency: false});
+const sessionDB = session.getDatabase(dbName);
+const sessionColl = sessionDB.getCollection(collName);
+
+jsTestLog("Test that we can't call prepareTransaction if there was never a transaction on " +
+ "the session");
+assert.commandFailedWithCode(
+ sessionDB.adminCommand(
+ {prepareTransaction: 1, txnNumber: NumberLong(0), stmtId: NumberInt(1), autocommit: false}),
+ ErrorCodes.NoSuchTransaction);
+
+jsTestLog("Test that we can't call prepareTransaction if the most recent transaction was aborted");
+session.startTransaction();
+assert.commandWorked(sessionColl.insert({_id: 1}));
+assert.commandWorked(session.abortTransaction_forTesting());
+
+assert.commandFailedWithCode(
+ sessionDB.adminCommand(
+ {prepareTransaction: 1, txnNumber: NumberLong(0), stmtId: NumberInt(1), autocommit: false}),
+ ErrorCodes.NoSuchTransaction);
+
+jsTestLog(
+ "Test that we can't call prepareTransaction if the most recent transaction was committed");
+session.startTransaction();
+assert.commandWorked(sessionColl.insert({_id: 1}));
+assert.commandWorked(session.commitTransaction_forTesting());
+
+assert.commandFailedWithCode(
+ sessionDB.adminCommand(
+ {prepareTransaction: 1, txnNumber: NumberLong(1), stmtId: NumberInt(1), autocommit: false}),
+ ErrorCodes.TransactionCommitted);
+
+session.endSession();
}());