Skip to content

Commit

Permalink
chore: add test for header/footer in multi package PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Nov 30, 2023
1 parent 72e916f commit 2ae5c7f
Showing 1 changed file with 109 additions and 77 deletions.
186 changes: 109 additions & 77 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1750,90 +1750,122 @@ describe('Manifest', () => {
);
});

it('should handle multiple package repository', async () => {
mockReleases(sandbox, github, [
{
id: 123456,
sha: 'abc123',
tagName: 'pkg1-v1.0.0',
url: 'https://github.com/fake-owner/fake-repo/releases/tag/pkg1-v1.0.0',
},
{
id: 654321,
sha: 'def234',
tagName: 'pkg2-v0.2.3',
url: 'https://github.com/fake-owner/fake-repo/releases/tag/pkg2-v0.2.3',
},
]);
mockCommits(sandbox, github, [
{
sha: 'aaaaaa',
message: 'fix: some bugfix',
files: ['path/a/foo'],
},
{
sha: 'abc123',
message: 'chore: release main',
files: [],
pullRequest: {
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 123,
title: 'chore: release main',
body: '',
labels: [],
files: [],
describe('with multiple packages', () => {
beforeEach(() => {
mockReleases(sandbox, github, [
{
id: 123456,
sha: 'abc123',
tagName: 'pkg1-v1.0.0',
url: 'https://github.com/fake-owner/fake-repo/releases/tag/pkg1-v1.0.0',
},
},
{
sha: 'bbbbbb',
message: 'fix: some bugfix',
files: ['path/b/foo'],
},
{
sha: 'cccccc',
message: 'fix: some bugfix',
files: ['path/a/foo'],
},
{
sha: 'def234',
message: 'chore: release main',
files: [],
pullRequest: {
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 123,
title: 'chore: release main',
body: '',
labels: [],
{
id: 654321,
sha: 'def234',
tagName: 'pkg2-v0.2.3',
url: 'https://github.com/fake-owner/fake-repo/releases/tag/pkg2-v0.2.3',
},
]);
mockCommits(sandbox, github, [
{
sha: 'aaaaaa',
message: 'fix: some bugfix',
files: ['path/a/foo'],
},
{
sha: 'abc123',
message: 'chore: release main',
files: [],
pullRequest: {
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 123,
title: 'chore: release main',
body: '',
labels: [],
files: [],
sha: 'abc123',
},
},
{
sha: 'bbbbbb',
message: 'fix: some bugfix',
files: ['path/b/foo'],
},
{
sha: 'cccccc',
message: 'fix: some bugfix',
files: ['path/a/foo'],
},
{
sha: 'def234',
message: 'chore: release main',
files: [],
pullRequest: {
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 123,
title: 'chore: release main',
body: '',
labels: [],
files: [],
sha: 'def234',
},
},
},
]);
const manifest = new Manifest(
github,
'main',
{
'path/a': {
releaseType: 'simple',
component: 'pkg1',
]);
});
it('should handle multiple package repository', async () => {
const manifest = new Manifest(
github,
'main',
{
'path/a': {
releaseType: 'simple',
component: 'pkg1',
},
'path/b': {
releaseType: 'simple',
component: 'pkg2',
},
},
'path/b': {
releaseType: 'simple',
component: 'pkg2',
{
'path/a': Version.parse('1.0.0'),
'path/b': Version.parse('0.2.3'),
}
);
const pullRequests = await manifest.buildPullRequests();
expect(pullRequests).lengthOf(1);
expect(pullRequests[0].labels).to.eql(['autorelease: pending']);
snapshot(dateSafe(pullRequests[0].body.toString()));
});

it('should handle pull request header/footer with multiple packages', async () => {
const manifest = new Manifest(
github,
'main',
{
'path/a': {
releaseType: 'simple',
component: 'pkg1',
pullRequestHeader: 'Header from pkg1',
},
'path/b': {
releaseType: 'simple',
component: 'pkg2',
pullRequestFooter: 'Footer from pkg2',
},
},
},
{
'path/a': Version.parse('1.0.0'),
'path/b': Version.parse('0.2.3'),
}
);
const pullRequests = await manifest.buildPullRequests();
expect(pullRequests).lengthOf(1);
expect(pullRequests[0].labels).to.eql(['autorelease: pending']);
snapshot(dateSafe(pullRequests[0].body.toString()));
{
'path/a': Version.parse('1.0.0'),
'path/b': Version.parse('0.2.3'),
}
);
const pullRequests = await manifest.buildPullRequests();
expect(pullRequests).lengthOf(1);
const pullRequest = pullRequests[0];
expect(pullRequest.body.header.toString()).to.eql('Header from pkg1');
expect(pullRequest.body.footer.toString()).to.eql('Footer from pkg2');
});
});

it('should allow creating multiple pull requests', async () => {
Expand Down

0 comments on commit 2ae5c7f

Please sign in to comment.