backport
Version:
A CLI tool that automates the process of backporting commits
50 lines • 2.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const childProcessHelper_1 = require("../../../test/childProcessHelper");
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
const sandbox_1 = require("../../../test/sandbox");
const getRepoOwnerAndNameFromGitRemotes_1 = require("./getRepoOwnerAndNameFromGitRemotes");
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
describe('fetchRemoteProjectConfig', () => {
describe('when the remote is a fork', () => {
it('retrives the original owner from github', async () => {
await (0, sandbox_1.resetSandbox)(sandboxPath);
const execOpts = { cwd: sandboxPath };
await (0, childProcessHelper_1.exec)(`git init`, execOpts);
await (0, childProcessHelper_1.exec)(`git remote add sorenlouv git@github.com:sorenlouv/kibana.git`, execOpts);
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
accessToken,
cwd: sandboxPath,
})).toEqual({
repoName: 'kibana',
repoOwner: 'elastic',
});
});
});
describe('when none of the git remotes are found', () => {
it('swallows the error and returns empty', async () => {
await (0, sandbox_1.resetSandbox)(sandboxPath);
const execOpts = { cwd: sandboxPath };
await (0, childProcessHelper_1.exec)(`git init`, execOpts);
await (0, childProcessHelper_1.exec)(`git remote add foo git@github.com:foo/kibana.git`, execOpts);
await (0, childProcessHelper_1.exec)(`git remote add bar git@github.com:bar/kibana.git`, execOpts);
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
accessToken,
cwd: sandboxPath,
})).toEqual({});
});
});
describe('when there are no git remotes', () => {
it('returns empty', async () => {
await (0, sandbox_1.resetSandbox)(sandboxPath);
const execOpts = { cwd: sandboxPath };
await (0, childProcessHelper_1.exec)(`git init`, execOpts);
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
accessToken,
cwd: sandboxPath,
})).toEqual({});
});
});
});
//# sourceMappingURL=getRepoOwnerAndNameFromGitRemotes.private.test.js.map