chore(scaffolder): added some more tests and more refactoring

This commit is contained in:
blam
2020-06-25 23:39:36 +02:00
parent 5a88ef753b
commit 1655b8c16e
2 changed files with 33 additions and 29 deletions
@@ -16,33 +16,37 @@
import { JobProcessor } from './processor';
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
describe('JobProcessor', () => {
const mockEntity: TemplateEntityV1alpha1 = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Template',
metadata: {
annotations: {
'backstage.io/managed-by-location':
'github:https://github.com/benjdlambert/backstage-graphql-template/blob/master/template.yaml',
},
name: 'graphql-starter',
title: 'GraphQL Service',
description:
'A GraphQL starter template for backstage to get you up and running\nthe best pracices with GraphQL\n',
uid: '9cf16bad-16e0-4213-b314-c4eec773c50b',
etag: 'ZTkxMjUxMjUtYWY3Yi00MjU2LWFkYWMtZTZjNjU5ZjJhOWM2',
generation: 1,
},
spec: {
type: 'cookiecutter',
path: './template',
},
};
describe('create', () => {
const mockEntity: TemplateEntityV1alpha1 = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Template',
metadata: {
annotations: {
'backstage.io/managed-by-location':
'github:https://github.com/benjdlambert/backstage-graphql-template/blob/master/template.yaml',
},
name: 'graphql-starter',
title: 'GraphQL Service',
description:
'A GraphQL starter template for backstage to get you up and running\nthe best pracices with GraphQL\n',
uid: '9cf16bad-16e0-4213-b314-c4eec773c50b',
etag: 'ZTkxMjUxMjUtYWY3Yi00MjU2LWFkYWMtZTZjNjU5ZjJhOWM2',
it.todo('creates a new job');
});
generation: 1,
},
spec: {
type: 'cookiecutter',
path: './template',
},
};
const processor = new JobProcessor();
it('should create a unique id for the job', async () => {
const job = processor.create();
});
describe('process', () => {
it.todo('allows running of a job in a pending state');
it.todo('fails when the job is not in a pending state');
it.todo('calls the preparer with the entity');
it.todo('calls the templater with the correct directory');
});
});
@@ -100,7 +100,7 @@ describe('CookieCutter Templater', () => {
imageName: 'backstage/cookiecutter',
args: ['cookiecutter', '--no-input', '-o', '/result', '/template'],
templateDir: tempdir,
resultDir: `${tempdir}/result`,
resultDir: `${tempdir}-result`,
logStream: undefined,
dockerClient: mockDocker,
});
@@ -119,7 +119,7 @@ describe('CookieCutter Templater', () => {
dockerClient: mockDocker,
});
expect(path).toBe(`${tempdir}/result`);
expect(path).toBe(`${tempdir}-result`);
});
it('should pass through the streamer to the run docker helper', async () => {
@@ -143,7 +143,7 @@ describe('CookieCutter Templater', () => {
imageName: 'backstage/cookiecutter',
args: ['cookiecutter', '--no-input', '-o', '/result', '/template'],
templateDir: tempdir,
resultDir: `${tempdir}/result`,
resultDir: `${tempdir}-result`,
logStream: stream,
dockerClient: mockDocker,
});