Skip to content

Commit

Permalink
test: extra testcase for using url with multiple variable
Browse files Browse the repository at this point in the history
  • Loading branch information
awcjack committed Apr 26, 2022
1 parent 1043c71 commit c454d4c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/publish.test.js
Expand Up @@ -363,3 +363,43 @@ test.serial('Publish a release with an asset link with same variable multiple ti
t.deepEqual(t.context.log.args[0], ['Published GitLab release: %s', nextRelease.gitTag]);
t.true(gitlab.isDone());
});

test.serial('Publish a release with an asset link with multiple variable', async t => {
const cwd = 'test/fixtures/files';
const owner = 'test_user';
const repo = 'test_repo';
process.env.repo = 'gitlab';
process.env.group = 'gitlab-org';
const env = {GITLAB_TOKEN: 'gitlab_token'};
const nextRelease = {gitHead: '123', gitTag: 'v1.0.0', notes: 'Test release note body'};
const options = {repositoryUrl: `https://gitlab.com/${owner}/${repo}.git`};
const encodedRepoId = encodeURIComponent(`${owner}/${repo}`);
const encodedGitTag = encodeURIComponent(nextRelease.gitTag);
const link = {
label: 'README.md',
type: 'other',
url: 'https://gitlab.com/${group}/${repo}/-/blob/master/README.md', // eslint-disable-line no-template-curly-in-string
};
const assets = [link];
const gitlab = authenticate(env)
.post(`/projects/${encodedRepoId}/releases`, {
tag_name: nextRelease.gitTag,
description: nextRelease.notes,
assets: {
links: [
{
name: 'README.md',
url: `https://gitlab.com/gitlab-org/gitlab/-/blob/master/README.md`,
link_type: 'other',
},
],
},
})
.reply(200);

const result = await publish({assets}, {env, cwd, options, nextRelease, logger: t.context.logger});

t.is(result.url, `https://gitlab.com/${encodedRepoId}/-/releases/${encodedGitTag}`);
t.deepEqual(t.context.log.args[0], ['Published GitLab release: %s', nextRelease.gitTag]);
t.true(gitlab.isDone());
});

0 comments on commit c454d4c

Please sign in to comment.