Fixed cloud runner tests failing when using a ssh remote.
parent
e1f453126e
commit
4aa6476cdb
|
|
@ -4925,7 +4925,7 @@ class GitRepoReader {
|
||||||
const value = (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
|
const value = (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
|
||||||
cloud_runner_logger_1.default.log(`value ${value}`);
|
cloud_runner_logger_1.default.log(`value ${value}`);
|
||||||
console_1.assert(value.includes('github.com'));
|
console_1.assert(value.includes('github.com'));
|
||||||
return value.split('github.com/')[1].split('.git')[0];
|
return value.split('github.com')[1].split('.git')[0].slice(1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static GetBranch() {
|
static GetBranch() {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -92,7 +92,6 @@ describe('Cloud Runner', () => {
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
it('Local cloud runner returns commands', async () => {
|
it('Local cloud runner returns commands', async () => {
|
||||||
// Build parameters
|
// Build parameters
|
||||||
Cli.options = {
|
Cli.options = {
|
||||||
|
|
@ -122,7 +121,6 @@ describe('Cloud Runner', () => {
|
||||||
delete Cli.options;
|
delete Cli.options;
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
|
|
||||||
|
|
||||||
it('Test cloud runner returns commands', async () => {
|
it('Test cloud runner returns commands', async () => {
|
||||||
// Build parameters
|
// Build parameters
|
||||||
Cli.options = {
|
Cli.options = {
|
||||||
|
|
@ -143,6 +141,4 @@ describe('Cloud Runner', () => {
|
||||||
Input.githubInputEnabled = true;
|
Input.githubInputEnabled = true;
|
||||||
delete Cli.options;
|
delete Cli.options;
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,24 @@
|
||||||
import { GitRepoReader } from './git-repo';
|
import { GitRepoReader } from './git-repo';
|
||||||
|
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
|
||||||
|
import Input from '../input';
|
||||||
|
|
||||||
describe(`git repo tests`, () => {
|
describe(`git repo tests`, () => {
|
||||||
it(`Branch value parsed from CLI to not contain illegal characters`, async () => {
|
it(`Branch value parsed from CLI to not contain illegal characters`, async () => {
|
||||||
expect(await GitRepoReader.GetBranch()).not.toContain(`\n`);
|
expect(await GitRepoReader.GetBranch()).not.toContain(`\n`);
|
||||||
expect(await GitRepoReader.GetBranch()).not.toContain(` `);
|
expect(await GitRepoReader.GetBranch()).not.toContain(` `);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`returns valid branch name when using https`, async () => {
|
||||||
|
const mockValue = 'https://github.com/example/example.git';
|
||||||
|
await jest.spyOn(CloudRunnerSystem, 'Run').mockReturnValue(Promise.resolve(mockValue));
|
||||||
|
await jest.spyOn(Input, 'cloudRunnerCluster', 'get').mockReturnValue('not-local');
|
||||||
|
expect(await GitRepoReader.GetRemote()).toEqual(`example/example`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`returns valid branch name when using ssh`, async () => {
|
||||||
|
const mockValue = 'git@github.com:example/example.git';
|
||||||
|
await jest.spyOn(CloudRunnerSystem, 'Run').mockReturnValue(Promise.resolve(mockValue));
|
||||||
|
await jest.spyOn(Input, 'cloudRunnerCluster', 'get').mockReturnValue('not-local');
|
||||||
|
expect(await GitRepoReader.GetRemote()).toEqual(`example/example`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export class GitRepoReader {
|
||||||
CloudRunnerLogger.log(`value ${value}`);
|
CloudRunnerLogger.log(`value ${value}`);
|
||||||
assert(value.includes('github.com'));
|
assert(value.includes('github.com'));
|
||||||
|
|
||||||
return value.split('github.com/')[1].split('.git')[0];
|
return value.split('github.com')[1].split('.git')[0].slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async GetBranch() {
|
public static async GetBranch() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue