Skip to content

Commit

Permalink
fix: handle undefined GitHub prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Feb 2, 2018
1 parent bc45bd0 commit 27d7828
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/resolve-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const {castArray} = require('lodash');
module.exports = ({githubUrl, githubApiPathPrefix, assets}) => ({
githubToken: process.env.GH_TOKEN || process.env.GITHUB_TOKEN,
githubUrl: githubUrl || process.env.GH_URL || process.env.GITHUB_URL,
githubApiPathPrefix: githubApiPathPrefix || process.env.GH_PREFIX || process.env.GITHUB_PREFIX,
githubApiPathPrefix: githubApiPathPrefix || process.env.GH_PREFIX || process.env.GITHUB_PREFIX || '',
assets: assets ? castArray(assets) : assets,
});
19 changes: 18 additions & 1 deletion test/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test.serial('Verify package, token and repository access', async t => {
t.true(github.isDone());
});

test.serial('Verify package, token and repository access and custom URL', async t => {
test.serial('Verify package, token and repository access and custom URL with prefix', async t => {
const owner = 'test_user';
const repo = 'test_repo';
process.env.GH_TOKEN = 'github_token';
Expand All @@ -66,6 +66,23 @@ test.serial('Verify package, token and repository access and custom URL', async
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication (%s)', 'https://othertesturl.com:9090/prefix']);
});

test.serial('Verify package, token and repository access and custom URL without prefix', async t => {
const owner = 'test_user';
const repo = 'test_repo';
process.env.GH_TOKEN = 'github_token';
const githubUrl = 'https://othertesturl.com:9090';
const github = authenticate({githubUrl})
.get(`/repos/${owner}/${repo}`)
.reply(200, {permissions: {push: true}});

await t.notThrows(
verify({githubUrl}, {repositoryUrl: `git@othertesturl.com:${owner}/${repo}.git`}, t.context.logger)
);

t.true(github.isDone());
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication (%s)', 'https://othertesturl.com:9090']);
});

test.serial('Verify package, token and repository with environment variables', async t => {
const owner = 'test_user';
const repo = 'test_repo';
Expand Down

0 comments on commit 27d7828

Please sign in to comment.