Tests for fixing #7021 to ensure file permissions are copied when templating

Signed-off-by: Christopher Zorn <czorn@flexport.com>
This commit is contained in:
Christopher Zorn
2021-09-01 14:47:58 -07:00
parent 652a2e9276
commit ed1100739c
2 changed files with 12 additions and 1 deletions
@@ -146,6 +146,10 @@ describe('fetch:template', () => {
mockFetchContents.mockImplementation(({ outputPath }) => {
mockFs({
[outputPath]: {
'an-executable.sh': mockFs.file({
content: '#!/usr/bin/env bash',
mode: parseInt('100755', 8),
}),
'empty-dir-${{ values.count }}': {},
'static.txt': 'static content',
'${{ values.name }}.txt': 'static content',
@@ -211,6 +215,13 @@ describe('fetch:template', () => {
fs.readFile(`${workspacePath}/target/a-binary-file.png`),
).resolves.toEqual(aBinaryFile);
});
it('copies files and maintains the original file permissions', async () => {
await expect(
fs
.stat(`${workspacePath}/target/an-executable.sh`)
.then(fObj => fObj.mode),
).resolves.toEqual(parseInt('100755', 8));
});
});
describe('copyWithoutRender', () => {
@@ -272,8 +272,8 @@ export function createFetchTemplateAction(options: {
renderContents
? templater.renderString(inputFileContents, context)
: inputFileContents,
{ mode: statsObj.mode },
);
await fs.chmod(outputPath, statsObj.mode);
}
}
}