File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
test/integration/transactions Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { expect } from 'chai' ;
2
2
import * as semver from 'semver' ;
3
3
4
- import { type MongoClient } from '../../mongodb' ;
4
+ import { type MongoClient , type ObjectId } from '../../mongodb' ;
5
5
6
6
const metadata : MongoDBMetadataUI = {
7
7
requires : {
@@ -51,16 +51,18 @@ describe('Transactions Spec Prose', function () {
51
51
'1.0 Write concern not inherited from collection object inside transaction.' ,
52
52
metadata ,
53
53
async ( ) => {
54
+ let _id : ObjectId ;
55
+ const collection = client . db ( ) . collection ( 'txn-test' , { writeConcern : { w : 0 } } ) ;
56
+
54
57
await client . withSession ( async session => {
55
58
session . startTransaction ( ) ;
56
-
57
- const collection = client . db ( ) . collection ( 'txn-test' , { writeConcern : { w : 0 } } ) ;
58
-
59
- await collection . insertOne ( { n : 1 } , { session } ) ;
60
-
59
+ _id = ( await collection . insertOne ( { n : 1 } , { session } ) ) . insertedId ;
61
60
await session . commitTransaction ( ) ;
62
61
} ) ;
63
62
63
+ // keep finding until we get a result, otherwise the test will timeout.
64
+ while ( ( await collection . findOne ( { _id } ) ) == null ) ;
65
+
64
66
const insertStarted = started . find ( ev => ev . commandName === 'insert' ) ;
65
67
expect ( insertStarted ) . to . not . have . nested . property ( 'command.writeConcern' ) ;
66
68
You can’t perform that action at this time.
0 commit comments