From 4178587bb248bfd03537570887377b0c94653ea0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 20 Jan 2026 17:33:48 +0100 Subject: [PATCH] backend-test-utils: move reusable test failure case (#32388) Signed-off-by: Patrik Oldsberg --- .../src/filesystem/MockDirectory.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/backend-test-utils/src/filesystem/MockDirectory.test.ts b/packages/backend-test-utils/src/filesystem/MockDirectory.test.ts index fd22f09432..82d46d361b 100644 --- a/packages/backend-test-utils/src/filesystem/MockDirectory.test.ts +++ b/packages/backend-test-utils/src/filesystem/MockDirectory.test.ts @@ -271,14 +271,16 @@ describe('createMockDirectory', () => { }); it('should reject non-child paths', () => { - const path = mockDir.resolve('/root/a.txt'); - expect(() => mockDir.setContent({ '/root/a.txt': 'a' })).toThrow( + const pathOutside = createMockDirectory().path; + + const path = mockDir.resolve(pathOutside); + expect(() => mockDir.setContent({ [pathOutside]: 'a' })).toThrow( `Provided path must resolve to a child path of the mock directory, got '${path}'`, ); - expect(() => mockDir.addContent({ '/root/a.txt': 'a' })).toThrow( + expect(() => mockDir.addContent({ [pathOutside]: 'a' })).toThrow( `Provided path must resolve to a child path of the mock directory, got '${path}'`, ); - expect(() => mockDir.content({ path: '/root/a.txt' })).toThrow( + expect(() => mockDir.content({ path: pathOutside })).toThrow( `Provided path must resolve to a child path of the mock directory, got '${path}'`, ); });