@@ -2,7 +2,7 @@ import os from 'os';
22import pathNode from 'path' ;
33import fs from 'fs' ;
44import Logger , { LogLevel , StreamHandler } from '@matrixai/logger' ;
5- import { DB } from '@matrixai/db' ;
5+ import { DB , errors as dbErrors } from '@matrixai/db' ;
66import INodeManager from '@/inodes/INodeManager' ;
77import * as utils from '@/utils' ;
88import * as permissions from '@/permissions' ;
@@ -89,16 +89,24 @@ describe('INodeManager', () => {
8989 await iNodeMgr . withTransactionF ( async ( tran ) => {
9090 await tran . put ( [ ...iNodeMgr . mgrDbPath , 'test' ] , 0 ) ;
9191 } ) ;
92- await Promise . all ( [
93- iNodeMgr . withTransactionF ( async ( tran ) => {
94- const num = ( await tran . get < number > ( [ ...iNodeMgr . mgrDbPath , 'test' ] ) ) ! ;
95- await tran . put ( [ ...iNodeMgr . mgrDbPath , 'test' ] , num + 1 ) ;
96- } ) ,
97- iNodeMgr . withTransactionF ( async ( tran ) => {
98- const num = ( await tran . get < number > ( [ ...iNodeMgr . mgrDbPath , 'test' ] ) ) ! ;
99- await tran . put ( [ ...iNodeMgr . mgrDbPath , 'test' ] , num + 1 ) ;
100- } ) ,
101- ] ) ;
92+ await expect (
93+ Promise . all ( [
94+ iNodeMgr . withTransactionF ( async ( tran ) => {
95+ const num = ( await tran . get < number > ( [
96+ ...iNodeMgr . mgrDbPath ,
97+ 'test' ,
98+ ] ) ) ! ;
99+ await tran . put ( [ ...iNodeMgr . mgrDbPath , 'test' ] , num + 1 ) ;
100+ } ) ,
101+ iNodeMgr . withTransactionF ( async ( tran ) => {
102+ const num = ( await tran . get < number > ( [
103+ ...iNodeMgr . mgrDbPath ,
104+ 'test' ,
105+ ] ) ) ! ;
106+ await tran . put ( [ ...iNodeMgr . mgrDbPath , 'test' ] , num + 1 ) ;
107+ } ) ,
108+ ] ) ,
109+ ) . rejects . toThrow ( dbErrors . ErrorDBTransactionConflict ) ;
102110 await iNodeMgr . withTransactionF ( async ( tran ) => {
103111 const num = ( await tran . get < number > ( [ ...iNodeMgr . mgrDbPath , 'test' ] ) ) ! ;
104112 // Race condition clobbers the counter
0 commit comments