chore: code review comments

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2021-07-07 11:02:31 +02:00
parent 4d9264f0fc
commit 8e183acc9c
@@ -28,7 +28,7 @@ import {
} from '@backstage/backend-common';
import { ConfigReader, JsonObject } from '@backstage/config';
import { ScmIntegrations } from '@backstage/integration';
import mock from 'mock-fs';
import mockFs from 'mock-fs';
import os from 'os';
import { PassThrough } from 'stream';
import { createFetchCookiecutterAction } from './cookiecutter';
@@ -94,14 +94,14 @@ describe('fetch:cookiecutter', () => {
};
// mock the temp directory
mock({ [mockTmpDir]: {} });
mock({ [`${join(mockTmpDir, 'template')}`]: {} });
mockFs({ [mockTmpDir]: {} });
mockFs({ [`${join(mockTmpDir, 'template')}`]: {} });
commandExists.mockResolvedValue(null);
// Mock when run container is called it creates some new files in the mock filesystem
containerRunner.runContainer.mockImplementation(async () => {
mock({
mockFs({
[`${join(mockTmpDir, 'intermediate')}`]: {
'testfile.json': '{}',
},
@@ -110,7 +110,7 @@ describe('fetch:cookiecutter', () => {
// Mock when runCommand is called it creats some new files in the mock filesystem
runCommand.mockImplementation(async () => {
mock({
mockFs({
[`${join(mockTmpDir, 'intermediate')}`]: {
'testfile.json': '{}',
},
@@ -119,26 +119,22 @@ describe('fetch:cookiecutter', () => {
});
afterEach(() => {
mock.restore();
mockFs.restore();
});
it('should throw an error when copyWithoutRender is not an array', async () => {
(mockContext.input as any).copyWithoutRender = 'not an array';
await expect(
action.handler(mockContext),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Fetch action input copyWithoutRender must be an Array"`,
await expect(action.handler(mockContext)).rejects.toThrowError(
/Fetch action input copyWithoutRender must be an Array/,
);
});
it('should throw an error when extensions is not an array', async () => {
(mockContext.input as any).extensions = 'not an array';
await expect(
action.handler(mockContext),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Fetch action input extensions must be an Array"`,
await expect(action.handler(mockContext)).rejects.toThrowError(
/Fetch action input extensions must be an Array/,
);
});