chore: adding test for this bug

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2021-11-24 14:01:26 +01:00
parent 92405f32bb
commit 5fd0e077bc
2 changed files with 26 additions and 1 deletions
@@ -270,6 +270,31 @@ describe('DefaultWorkflowRunner', () => {
);
});
it('should not try and parse something that is not parsable', async () => {
jest.spyOn(logger, 'error');
const task = createMockTaskWithSpec({
apiVersion: 'scaffolder.backstage.io/v1beta3',
steps: [
{
id: 'test',
name: 'name',
action: 'jest-mock-action',
input: {
foo: 'bob',
},
},
],
output: {},
parameters: {
input: 'BACKSTAGE',
},
});
await runner.execute(task);
expect(logger.error).not.toHaveBeenCalled();
});
it('should keep the original types for the input and not parse things that arent meant to be parsed', async () => {
const task = createMockTaskWithSpec({
apiVersion: 'scaffolder.backstage.io/v1beta3',
@@ -148,7 +148,7 @@ export class NunjucksWorkflowRunner implements WorkflowRunner {
return JSON.parse(templated);
}
} catch (ex) {
console.error(
this.options.logger.error(
`Failed to parse template string: ${value} with error ${ex.message}`,
);
}