fetch:template - test binary files are copied over
Signed-off-by: Himanshu Mishra <himanshu@orkohunter.net>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import os from 'os';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import mockFs from 'mock-fs';
|
||||
import { getVoidLogger, UrlReader } from '@backstage/backend-common';
|
||||
@@ -24,12 +25,17 @@ import { fetchContents } from './helpers';
|
||||
import { ActionContext, TemplateAction } from '../../types';
|
||||
import { createFetchTemplateAction, FetchTemplateInput } from './template';
|
||||
|
||||
// TODO(mtlewis/orkohunter): Test handling binary files
|
||||
|
||||
jest.mock('./helpers', () => ({
|
||||
fetchContents: jest.fn(),
|
||||
}));
|
||||
|
||||
const aBinaryFile = fs.readFileSync(
|
||||
resolvePath(
|
||||
'src',
|
||||
'../fixtures/test-nested-template/public/react-logo192.png',
|
||||
),
|
||||
);
|
||||
|
||||
const mockFetchContents = fetchContents as jest.MockedFunction<
|
||||
typeof fetchContents
|
||||
>;
|
||||
@@ -119,6 +125,7 @@ describe('fetch:template', () => {
|
||||
'templated-content.txt': '${{ name }}: ${{ count }}',
|
||||
},
|
||||
'.${{ name }}': '${{ itemList | dump }}',
|
||||
'a-binary-file.png': aBinaryFile,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -169,6 +176,12 @@ describe('fetch:template', () => {
|
||||
fs.readdir(`${workspacePath}/target/empty-dir-1234`, 'utf-8'),
|
||||
).resolves.toEqual([]);
|
||||
});
|
||||
|
||||
it('copies binary files as it-is without processing them', async () => {
|
||||
await expect(
|
||||
fs.readFile(`${workspacePath}/target/a-binary-file.png`),
|
||||
).resolves.toEqual(aBinaryFile);
|
||||
});
|
||||
});
|
||||
|
||||
describe('copyWithoutRender', () => {
|
||||
|
||||
Reference in New Issue
Block a user