Merge pull request #4304 from backstage/jhaals/fix-scaffolder-tests
Scaffolder: Fix tests in windows
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import os from 'os';
|
||||
import { JobProcessor } from './processor';
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import { StageInput } from './types';
|
||||
@@ -68,9 +69,11 @@ describe('JobProcessor', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const workingDirectory = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
|
||||
describe('create', () => {
|
||||
it('creates should create a new job with a unique id', async () => {
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
@@ -84,7 +87,7 @@ describe('JobProcessor', () => {
|
||||
});
|
||||
|
||||
it('should setup the correct context for the job', async () => {
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
@@ -97,7 +100,7 @@ describe('JobProcessor', () => {
|
||||
});
|
||||
|
||||
it('should set the status as pending', async () => {
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
@@ -120,7 +123,7 @@ describe('JobProcessor', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
@@ -139,12 +142,12 @@ describe('JobProcessor', () => {
|
||||
|
||||
describe('get', () => {
|
||||
it('return undefined for when the job does not exist', () => {
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
expect(processor.get('123')).not.toBeDefined();
|
||||
});
|
||||
|
||||
it('should return the exact same instance of the job when one is created', async () => {
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
values: mockValues,
|
||||
@@ -156,7 +159,7 @@ describe('JobProcessor', () => {
|
||||
});
|
||||
describe('process', () => {
|
||||
it('throws an error when the status of the job is not in pending state', async () => {
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
values: mockValues,
|
||||
@@ -182,7 +185,7 @@ describe('JobProcessor', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
values: mockValues,
|
||||
@@ -208,7 +211,7 @@ describe('JobProcessor', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
values: mockValues,
|
||||
@@ -244,7 +247,7 @@ describe('JobProcessor', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
values: mockValues,
|
||||
@@ -283,7 +286,7 @@ describe('JobProcessor', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const processor = new JobProcessor('/tmp');
|
||||
const processor = new JobProcessor(workingDirectory);
|
||||
const job = processor.create({
|
||||
entity: mockEntity,
|
||||
values: mockValues,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import os from 'os';
|
||||
import { resolve } from 'path';
|
||||
import path from 'path';
|
||||
import { AzurePreparer } from './azure';
|
||||
import { getVoidLogger, Git } from '@backstage/backend-common';
|
||||
|
||||
@@ -37,8 +37,8 @@ describe('AzurePreparer', () => {
|
||||
});
|
||||
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const checkoutPath = resolve(workspacePath, 'checkout');
|
||||
const templatePath = resolve(workspacePath, 'template');
|
||||
const checkoutPath = path.resolve(workspacePath, 'checkout');
|
||||
const templatePath = path.resolve(workspacePath, 'template');
|
||||
const prepareOptions = {
|
||||
url:
|
||||
'https://dev.azure.com/backstage-org/backstage-project/_git/template-repo',
|
||||
@@ -54,7 +54,7 @@ describe('AzurePreparer', () => {
|
||||
username: 'notempty',
|
||||
});
|
||||
expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath);
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git'));
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git'));
|
||||
});
|
||||
|
||||
it('calls the clone command with the correct arguments for a repository', async () => {
|
||||
@@ -100,17 +100,16 @@ describe('AzurePreparer', () => {
|
||||
});
|
||||
|
||||
it('moves the template from path if it is specified', async () => {
|
||||
const path = './subdir';
|
||||
await preparer.prepare({
|
||||
url: `https://dev.azure.com/backstage-org/backstage-project/_git/template-repo?path=${encodeURIComponent(
|
||||
path,
|
||||
'./subdir',
|
||||
)}`,
|
||||
logger,
|
||||
workspacePath,
|
||||
});
|
||||
|
||||
expect(fs.move).toHaveBeenCalledWith(
|
||||
resolve(checkoutPath, 'subdir'),
|
||||
path.resolve(checkoutPath, 'subdir'),
|
||||
templatePath,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import fs from 'fs-extra';
|
||||
import { BitbucketPreparer } from './bitbucket';
|
||||
import { getVoidLogger, Git } from '@backstage/backend-common';
|
||||
import { resolve } from 'path';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
|
||||
jest.mock('fs-extra');
|
||||
@@ -41,8 +41,8 @@ describe('BitbucketPreparer', () => {
|
||||
});
|
||||
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const checkoutPath = resolve(workspacePath, 'checkout');
|
||||
const templatePath = resolve(workspacePath, 'template');
|
||||
const checkoutPath = path.resolve(workspacePath, 'checkout');
|
||||
const templatePath = path.resolve(workspacePath, 'template');
|
||||
|
||||
const prepareOptions = {
|
||||
url: 'https://bitbucket.org/backstage-project/backstage-repo',
|
||||
@@ -58,7 +58,7 @@ describe('BitbucketPreparer', () => {
|
||||
ref: expect.any(String),
|
||||
});
|
||||
expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath);
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git'));
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git'));
|
||||
});
|
||||
|
||||
it('calls the clone command with the correct arguments if an app password is provided for a repository', async () => {
|
||||
@@ -92,7 +92,7 @@ describe('BitbucketPreparer', () => {
|
||||
workspacePath,
|
||||
});
|
||||
expect(fs.move).toHaveBeenCalledWith(
|
||||
resolve(checkoutPath, '1', '2', '3'),
|
||||
path.resolve(checkoutPath, '1', '2', '3'),
|
||||
templatePath,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import { getVoidLogger } from '@backstage/backend-common';
|
||||
import fs from 'fs-extra';
|
||||
import { FilePreparer } from './file';
|
||||
import os from 'os';
|
||||
import { resolve } from 'path';
|
||||
import path from 'path';
|
||||
|
||||
jest.mock('fs-extra');
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('File preparer', () => {
|
||||
const logger = getVoidLogger();
|
||||
const preparer = new FilePreparer();
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const checkoutPath = resolve(workspacePath, 'checkout');
|
||||
const checkoutPath = path.resolve(workspacePath, 'checkout');
|
||||
|
||||
await preparer.prepare({
|
||||
url: 'file:///path/to/template',
|
||||
@@ -35,7 +35,7 @@ describe('File preparer', () => {
|
||||
workspacePath,
|
||||
});
|
||||
expect(fs.copy).toHaveBeenCalledWith(
|
||||
resolve('/path', 'to', 'template'),
|
||||
path.join('/path', 'to', 'template'),
|
||||
checkoutPath,
|
||||
{
|
||||
recursive: true,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import fs from 'fs-extra';
|
||||
import os from 'os';
|
||||
import { resolve } from 'path';
|
||||
import path from 'path';
|
||||
import { GithubPreparer } from './github';
|
||||
import { getVoidLogger, Git } from '@backstage/backend-common';
|
||||
|
||||
@@ -24,8 +24,8 @@ jest.mock('fs-extra');
|
||||
|
||||
describe('GitHubPreparer', () => {
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const checkoutPath = resolve(workspacePath, 'checkout');
|
||||
const templatePath = resolve(workspacePath, 'template');
|
||||
const checkoutPath = path.resolve(workspacePath, 'checkout');
|
||||
const templatePath = path.resolve(workspacePath, 'template');
|
||||
|
||||
const mockGitClient = {
|
||||
clone: jest.fn(),
|
||||
@@ -57,7 +57,7 @@ describe('GitHubPreparer', () => {
|
||||
ref: expect.any(String),
|
||||
});
|
||||
expect(fs.move).toHaveBeenCalledWith(
|
||||
resolve(checkoutPath, 'templates', 'graphql-starter', 'template'),
|
||||
path.resolve(checkoutPath, 'templates', 'graphql-starter', 'template'),
|
||||
templatePath,
|
||||
);
|
||||
expect(fs.rmdir).toHaveBeenCalledWith('/tmp/template/.git');
|
||||
@@ -77,7 +77,7 @@ describe('GitHubPreparer', () => {
|
||||
ref: 'master',
|
||||
});
|
||||
expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath);
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git'));
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git'));
|
||||
});
|
||||
|
||||
it('calls the clone command with token', async () => {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
import fs from 'fs-extra';
|
||||
import os from 'os';
|
||||
import { resolve } from 'path';
|
||||
import path from 'path';
|
||||
import { GitlabPreparer } from './gitlab';
|
||||
import { getVoidLogger, Git } from '@backstage/backend-common';
|
||||
|
||||
@@ -23,8 +23,8 @@ jest.mock('fs-extra');
|
||||
|
||||
describe('GitLabPreparer', () => {
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const checkoutPath = resolve(workspacePath, 'checkout');
|
||||
const templatePath = resolve(workspacePath, 'template');
|
||||
const checkoutPath = path.resolve(workspacePath, 'checkout');
|
||||
const templatePath = path.resolve(workspacePath, 'template');
|
||||
|
||||
const mockGitClient = {
|
||||
clone: jest.fn(),
|
||||
@@ -62,7 +62,7 @@ describe('GitLabPreparer', () => {
|
||||
});
|
||||
|
||||
expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath);
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git'));
|
||||
expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git'));
|
||||
});
|
||||
|
||||
it(`clones the template from a sub directory if specified`, async () => {
|
||||
@@ -73,7 +73,7 @@ describe('GitLabPreparer', () => {
|
||||
workspacePath,
|
||||
});
|
||||
expect(fs.move).toHaveBeenCalledWith(
|
||||
resolve(checkoutPath, '1', '2', '3'),
|
||||
path.resolve(checkoutPath, '1', '2', '3'),
|
||||
templatePath,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -20,6 +20,8 @@ jest.mock('azure-devops-node-api', () => ({
|
||||
getPersonalAccessTokenHandler: jest.fn().mockReturnValue(() => {}),
|
||||
}));
|
||||
|
||||
import os from 'os';
|
||||
import { resolve } from 'path';
|
||||
import { AzurePublisher } from './azure';
|
||||
import { WebApi } from 'azure-devops-node-api';
|
||||
import * as helpers from './helpers';
|
||||
@@ -28,6 +30,9 @@ import { getVoidLogger } from '@backstage/backend-common';
|
||||
describe('Azure Publisher', () => {
|
||||
const logger = getVoidLogger();
|
||||
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const resultPath = resolve(workspacePath, 'result');
|
||||
|
||||
describe('publish: createRemoteInAzure', () => {
|
||||
it('should use azure-devops-node-api to create a repo in the given project', async () => {
|
||||
const mockGitClient = {
|
||||
@@ -53,7 +58,7 @@ describe('Azure Publisher', () => {
|
||||
storePath: 'https://dev.azure.com/organisation/project/_git/repo',
|
||||
owner: 'bob',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -74,7 +79,7 @@ describe('Azure Publisher', () => {
|
||||
'project',
|
||||
);
|
||||
expect(helpers.initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://dev.azure.com/organization/project/_git/repo',
|
||||
auth: { username: 'notempty', password: 'fake-azure-token' },
|
||||
logger,
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
jest.mock('./helpers');
|
||||
|
||||
import os from 'os';
|
||||
import { resolve } from 'path';
|
||||
import { BitbucketPublisher } from './bitbucket';
|
||||
import { initRepoAndPush } from './helpers';
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
@@ -32,6 +34,9 @@ describe('Bitbucket Publisher', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const resultPath = resolve(workspacePath, 'result');
|
||||
|
||||
describe('publish: createRemoteInBitbucketCloud', () => {
|
||||
it('should create repo in bitbucket cloud', async () => {
|
||||
server.use(
|
||||
@@ -69,7 +74,7 @@ describe('Bitbucket Publisher', () => {
|
||||
storePath: 'https://bitbucket.org/project/repo',
|
||||
owner: 'bob',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger: logger,
|
||||
});
|
||||
|
||||
@@ -80,7 +85,7 @@ describe('Bitbucket Publisher', () => {
|
||||
});
|
||||
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://bitbucket.org/project/repo',
|
||||
auth: { username: 'fake-user', password: 'fake-token' },
|
||||
logger: logger,
|
||||
@@ -127,7 +132,7 @@ describe('Bitbucket Publisher', () => {
|
||||
storePath: 'https://bitbucket.mycompany.com/project/repo',
|
||||
owner: 'bob',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger: logger,
|
||||
});
|
||||
|
||||
@@ -138,7 +143,7 @@ describe('Bitbucket Publisher', () => {
|
||||
});
|
||||
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://bitbucket.mycompany.com/scm/project/repo',
|
||||
auth: { username: 'x-token-auth', password: 'fake-token' },
|
||||
logger: logger,
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
jest.mock('@octokit/rest');
|
||||
jest.mock('./helpers');
|
||||
|
||||
import os from 'os';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { Octokit, RestEndpointMethodTypes } from '@octokit/rest';
|
||||
import { GithubPublisher } from './github';
|
||||
@@ -36,6 +39,9 @@ describe('GitHub Publisher', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const resultPath = resolve(workspacePath, 'result');
|
||||
|
||||
describe('with public repo visibility', () => {
|
||||
describe('publish: createRemoteInGithub', () => {
|
||||
it('should use octokit to create a repo in an organisation if the organisation property is set', async () => {
|
||||
@@ -64,7 +70,7 @@ describe('GitHub Publisher', () => {
|
||||
owner: 'bob',
|
||||
access: 'blam/team',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -89,7 +95,7 @@ describe('GitHub Publisher', () => {
|
||||
permission: 'admin',
|
||||
});
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://github.com/backstage/backstage.git',
|
||||
auth: { username: 'fake-token', password: 'x-oauth-basic' },
|
||||
logger,
|
||||
@@ -122,7 +128,7 @@ describe('GitHub Publisher', () => {
|
||||
owner: 'bob',
|
||||
access: 'blam',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -140,7 +146,7 @@ describe('GitHub Publisher', () => {
|
||||
expect(mockGithubClient.repos.addCollaborator).not.toHaveBeenCalled();
|
||||
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://github.com/backstage/backstage.git',
|
||||
auth: { username: 'fake-token', password: 'x-oauth-basic' },
|
||||
logger,
|
||||
@@ -175,7 +181,7 @@ describe('GitHub Publisher', () => {
|
||||
access: 'bob',
|
||||
description: 'description',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -198,7 +204,7 @@ describe('GitHub Publisher', () => {
|
||||
permission: 'admin',
|
||||
});
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://github.com/backstage/backstage.git',
|
||||
auth: { username: 'fake-token', password: 'x-oauth-basic' },
|
||||
logger,
|
||||
@@ -233,7 +239,7 @@ describe('GitHub Publisher', () => {
|
||||
storePath: 'https://github.com/blam/test',
|
||||
owner: 'bob',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -249,7 +255,7 @@ describe('GitHub Publisher', () => {
|
||||
visibility: 'internal',
|
||||
});
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://github.com/backstage/backstage.git',
|
||||
auth: { username: 'fake-token', password: 'x-oauth-basic' },
|
||||
logger,
|
||||
@@ -283,7 +289,7 @@ describe('GitHub Publisher', () => {
|
||||
storePath: 'https://github.com/blam/test',
|
||||
owner: 'bob',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -299,7 +305,7 @@ describe('GitHub Publisher', () => {
|
||||
private: true,
|
||||
});
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'https://github.com/backstage/backstage.git',
|
||||
auth: { username: 'fake-token', password: 'x-oauth-basic' },
|
||||
logger,
|
||||
|
||||
@@ -20,6 +20,8 @@ jest.mock('@gitbeaker/node', () => ({
|
||||
|
||||
jest.mock('./helpers');
|
||||
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { GitlabPublisher } from './gitlab';
|
||||
import { Gitlab } from '@gitbeaker/node';
|
||||
import { initRepoAndPush } from './helpers';
|
||||
@@ -47,6 +49,9 @@ describe('GitLab Publisher', () => {
|
||||
);
|
||||
});
|
||||
|
||||
const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp';
|
||||
const resultPath = path.resolve(workspacePath, 'result');
|
||||
|
||||
describe('publish: createRemoteInGitLab', () => {
|
||||
it('should use gitbeaker to create a repo in a namespace if the namespace property is set', async () => {
|
||||
const publisher = await GitlabPublisher.fromConfig({
|
||||
@@ -68,7 +73,7 @@ describe('GitLab Publisher', () => {
|
||||
storePath: 'https://gitlab.com/blam/test',
|
||||
owner: 'bob',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -85,7 +90,7 @@ describe('GitLab Publisher', () => {
|
||||
name: 'test',
|
||||
});
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'mockclone',
|
||||
auth: { username: 'oauth2', password: 'fake-token' },
|
||||
logger,
|
||||
@@ -111,7 +116,7 @@ describe('GitLab Publisher', () => {
|
||||
storePath: 'https://gitlab.com/blam/test',
|
||||
owner: 'bob',
|
||||
},
|
||||
workspacePath: '/tmp/test',
|
||||
workspacePath,
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -125,7 +130,7 @@ describe('GitLab Publisher', () => {
|
||||
name: 'test',
|
||||
});
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: '/tmp/test/result',
|
||||
dir: resultPath,
|
||||
remoteUrl: 'mockclone',
|
||||
auth: { username: 'oauth2', password: 'fake-token' },
|
||||
logger,
|
||||
|
||||
@@ -24,6 +24,7 @@ jest.mock('fs-extra');
|
||||
|
||||
import { CookieCutter } from './cookiecutter';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import { PassThrough } from 'stream';
|
||||
import Docker from 'dockerode';
|
||||
import parseGitUrl from 'git-url-parse';
|
||||
@@ -56,7 +57,7 @@ describe('CookieCutter Templater', () => {
|
||||
});
|
||||
|
||||
expect(fs.writeJson).toBeCalledWith(
|
||||
'tempdir/template/cookiecutter.json',
|
||||
path.join('tempdir', 'template', 'cookiecutter.json'),
|
||||
expect.objectContaining(values),
|
||||
);
|
||||
});
|
||||
@@ -87,13 +88,16 @@ describe('CookieCutter Templater', () => {
|
||||
dockerClient: mockDocker,
|
||||
});
|
||||
|
||||
expect(fs.writeJSON).toBeCalledWith('tempdir/template/cookiecutter.json', {
|
||||
...existingJson,
|
||||
...values,
|
||||
destination: {
|
||||
git: expect.objectContaining({ organization: 'org', name: 'repo' }),
|
||||
expect(fs.writeJSON).toBeCalledWith(
|
||||
path.join('tempdir', 'template', 'cookiecutter.json'),
|
||||
{
|
||||
...existingJson,
|
||||
...values,
|
||||
destination: {
|
||||
git: expect.objectContaining({ organization: 'org', name: 'repo' }),
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error if the cookiecutter json is malformed and not missing', async () => {
|
||||
@@ -148,8 +152,8 @@ describe('CookieCutter Templater', () => {
|
||||
'/template',
|
||||
'--verbose',
|
||||
],
|
||||
templateDir: 'tempdir/template',
|
||||
resultDir: 'tempdir/intermediate',
|
||||
templateDir: path.join('tempdir', 'template'),
|
||||
resultDir: path.join('tempdir', 'intermediate'),
|
||||
logStream: undefined,
|
||||
dockerClient: mockDocker,
|
||||
});
|
||||
@@ -187,8 +191,8 @@ describe('CookieCutter Templater', () => {
|
||||
'/template',
|
||||
'--verbose',
|
||||
],
|
||||
templateDir: 'tempdir/template',
|
||||
resultDir: 'tempdir/intermediate',
|
||||
templateDir: path.join('tempdir', 'template'),
|
||||
resultDir: path.join('tempdir', 'intermediate'),
|
||||
logStream: stream,
|
||||
dockerClient: mockDocker,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user