Skip to content

Commit

Permalink
test: publish a release when env.GITHUB_URL is set to https://github.com
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed May 14, 2020
1 parent 8027e91 commit 27d615a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,38 @@ test.serial('Throw error without retries for 400 error', async (t) => {
t.is(error.status, 400);
t.true(github.isDone());
});

test.serial.only('Publish a release when env.GITHUB_URL is set to https://github.com (Default in GitHub Actions, #268)', async (t) => {
const owner = 'test_user';
const repo = 'test_repo';
const env = {GITHUB_TOKEN: 'github_token', GITHUB_URL: 'https://github.com', GITHUB_API_URL: 'https://api.github.com'};
const pluginConfig = {};
const nextRelease = {gitTag: 'v1.0.0', name: 'v1.0.0', notes: 'Test release note body'};
const options = {repositoryUrl: `https://github.com/${owner}/${repo}.git`};
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`;
const releaseId = 1;
const uploadUri = `/api/uploads/repos/${owner}/${repo}/releases/${releaseId}/assets`;
const uploadUrl = `https://github.com${uploadUri}{?name,label}`;

const github = authenticate({...env, GITHUB_TOKEN: 'https://api.github.com'})
.post(`/repos/${owner}/${repo}/releases`, {
tag_name: nextRelease.gitTag,
name: nextRelease.name,
body: nextRelease.notes,
prerelease: false,
})
.reply(200, {upload_url: uploadUrl, html_url: releaseUrl});

const result = await publish(pluginConfig, {
cwd,
env,
options,
branch: {type: 'release', main: true},
nextRelease,
logger: t.context.logger,
});

t.is(result.url, releaseUrl);
t.deepEqual(t.context.log.args[0], ['Published GitHub release: %s', releaseUrl]);
t.true(github.isDone());
});

0 comments on commit 27d615a

Please sign in to comment.