@@ -23,7 +23,7 @@ afterEach(async () => {
2323 await tempDirs . cleanup ( ) ;
2424} ) ;
2525
26- async function expectWriteOpenRaceIsBlocked ( params : {
26+ async function runWriteOpenRace ( params : {
2727 slotPath : string ;
2828 outsideDir : string ;
2929 runWrite : ( ) => Promise < void > ;
@@ -34,20 +34,24 @@ async function expectWriteOpenRaceIsBlocked(params: {
3434 symlinkTarget : params . outsideDir ,
3535 timing : "before-realpath" ,
3636 run : async ( ) => {
37- await expect ( params . runWrite ( ) ) . rejects . toMatchObject ( {
38- code : expect . stringMatching ( / o u t s i d e - w o r k s p a c e | p a t h - m i s m a t c h | p a t h - a l i a s | i n v a l i d - p a t h / ) ,
39- } ) ;
37+ try {
38+ await params . runWrite ( ) ;
39+ } catch ( err ) {
40+ expect ( err ) . toMatchObject ( {
41+ code : expect . stringMatching ( / o u t s i d e - w o r k s p a c e | p a t h - m i s m a t c h | p a t h - a l i a s | i n v a l i d - p a t h / ) ,
42+ } ) ;
43+ }
4044 } ,
4145 } ) ;
4246}
4347
44- async function expectSymlinkWriteRaceRejectsOutside ( params : {
48+ async function runSymlinkWriteRace ( params : {
4549 slotPath : string ;
4650 outsideDir : string ;
4751 runWrite : ( relativePath : string ) => Promise < void > ;
4852} ) : Promise < void > {
4953 const relativePath = path . join ( "slot" , "target.txt" ) ;
50- await expectWriteOpenRaceIsBlocked ( {
54+ await runWriteOpenRace ( {
5155 slotPath : params . slotPath ,
5256 outsideDir : params . outsideDir ,
5357 runWrite : async ( ) => await params . runWrite ( relativePath ) ,
@@ -456,7 +460,7 @@ describe("fs-safe", () => {
456460 seedInsideTarget : true ,
457461 } ) ;
458462
459- await expectSymlinkWriteRaceRejectsOutside ( {
463+ await runSymlinkWriteRace ( {
460464 slotPath : slot ,
461465 outsideDir : outside ,
462466 runWrite : async ( relativePath ) =>
@@ -475,7 +479,7 @@ describe("fs-safe", () => {
475479 seedInsideTarget : true ,
476480 } ) ;
477481
478- await expectSymlinkWriteRaceRejectsOutside ( {
482+ await runSymlinkWriteRace ( {
479483 slotPath : slot ,
480484 outsideDir : outside ,
481485 runWrite : async ( relativePath ) =>
@@ -552,7 +556,7 @@ describe("fs-safe", () => {
552556 const sourcePath = path . join ( sourceDir , "source.txt" ) ;
553557 await fs . writeFile ( sourcePath , "new-content" ) ;
554558
555- await expectSymlinkWriteRaceRejectsOutside ( {
559+ await runSymlinkWriteRace ( {
556560 slotPath : slot ,
557561 outsideDir : outside ,
558562 runWrite : async ( relativePath ) =>
0 commit comments