Skip to content

Commit

Permalink
Adding test for tag-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Devon Stewart committed Mar 4, 2022
1 parent b50e8dc commit 8569fff
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/fixtures/config/config-with-tag-prefix.yml
@@ -0,0 +1,7 @@
name-template: 'static-tag-prefix-v$RESOLVED_VERSION 🌈'
tag-template: 'static-tag-prefix-v$RESOLVED_VERSION'
tag-prefix: static-tag-prefix-v
template: |
## Previous release
$PREVIOUS_TAG
52 changes: 52 additions & 0 deletions test/index.test.js
Expand Up @@ -2831,6 +2831,58 @@ describe('release-drafter', () => {
})
})

describe('with tag-prefix', () => {
it('gets the version from the tag, stripping the prefix', async () => {
getConfigMock('config-with-tag-prefix.yml')
// Explicitly include a RC suffix in order to differentiate the
// behaviour of semver.parse vs semver.coerce in versions.js
//
// We expect the release to be 2.1.4, not 2.1.5
const alteredReleasePayload = {
...releasePayload,
tag_name: 'static-tag-prefix-v2.1.4-RC3',
}

nock('https://api.github.com')
.post('/graphql', (body) =>
body.query.includes('query findCommitsWithAssociatedPullRequests')
)
.reply(200, graphqlCommitsNoPRsPayload)

nock('https://api.github.com')
.get('/repos/toolmantim/release-drafter-test-project/releases')
.query(true)
.reply(200, [alteredReleasePayload])
.post(
'/repos/toolmantim/release-drafter-test-project/releases',
(body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"body": "## Previous release
static-tag-prefix-v2.1.4-RC3
",
"draft": true,
"name": "static-tag-prefix-v2.1.4 🌈",
"prerelease": false,
"tag_name": "static-tag-prefix-v2.1.4",
"target_commitish": "refs/heads/master",
}
`)
return true
}
)
.reply(200, alteredReleasePayload)

await probot.receive({
name: 'push',
payload: pushPayload,
})

expect.assertions(1)
})
})

describe('with custom version resolver', () => {
it('uses correct default when no labels exist', async () => {
getConfigMock('config-with-custom-version-resolver-none.yml')
Expand Down

0 comments on commit 8569fff

Please sign in to comment.