From c9bf1c98b5c5c04a39eaf2b4564a55496320f63b Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 8 Jul 2022 11:04:40 +0200 Subject: [PATCH] chore: added some tests to ensure that we skip symlinked folders and files Signed-off-by: blam --- .../files/serializeDirectoryContents.test.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/plugins/scaffolder-backend/src/lib/files/serializeDirectoryContents.test.ts b/plugins/scaffolder-backend/src/lib/files/serializeDirectoryContents.test.ts index e1ea676ec5..b24a867504 100644 --- a/plugins/scaffolder-backend/src/lib/files/serializeDirectoryContents.test.ts +++ b/plugins/scaffolder-backend/src/lib/files/serializeDirectoryContents.test.ts @@ -97,6 +97,52 @@ describe('serializeDirectoryContents', () => { ]); }); + it('should ignore symlinked files', async () => { + mockFs({ + root: { + 'a.txt': 'some text', + sym: mockFs.symlink({ + path: './a.txt', + }), + }, + }); + + await expect(serializeDirectoryContents('root')).resolves.toEqual([ + { + path: 'a.txt', + executable: false, + content: Buffer.from('some text', 'utf8'), + }, + ]); + }); + + it('should ignore symlinked folder files', async () => { + mockFs({ + root: { + 'a.txt': 'some text', + linkme: { + 'b.txt': 'lols', + }, + sym: mockFs.symlink({ + path: './linkme', + }), + }, + }); + + await expect(serializeDirectoryContents('root')).resolves.toEqual([ + { + path: 'a.txt', + executable: false, + content: Buffer.from('some text', 'utf8'), + }, + { + path: 'linkme/b.txt', + executable: false, + content: Buffer.from('lols', 'utf8'), + }, + ]); + }); + it('should ignore gitignored files', async () => { mockFs({ root: {