Skip to content

Commit

Permalink
test: failing test for respecting versioning strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 committed Jan 5, 2023
1 parent 542d412 commit c3deba7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
22 changes: 22 additions & 0 deletions __snapshots__/maven-workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,28 @@ Release notes for path: maven4, releaseType: maven
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['MavenWorkspace plugin run respects strategy versioning strategy 1'] = `
:robot: I have created a release *beep* *boop*
---
<details><summary>multi1-sub1: 2.3.0</summary>
Release notes for path: multi1/sub1, releaseType: java-yoshi
</details>
<details><summary>com.google.example:my-bom: 1.3.0</summary>
### Dependencies
* The following workspace dependencies were updated
* com.google.example:multi1-sub1 bumped to 2.3.0
</details>
---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['MavenWorkspace plugin run skips pom files not configured for release 1'] = `
:robot: I have created a release *beep* *boop*
---
Expand Down
46 changes: 46 additions & 0 deletions test/plugins/maven-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,52 @@ describe('MavenWorkspace plugin', () => {
expect(version.toString()).to.not.include('SNAPSHOT');
}
});
it('respects strategy versioning strategy', async () => {
// In this test, the BOM component is configured to use the dependency-manifest
// versioning strategy - when a dependency update commit is detected, it
// tries to match the semver bump type. The artifact that is part of the BOM
// is releasing a minor version bump, so the BOM should also take a minor
// version bump.
plugin = new MavenWorkspace(github, 'main', {
bom: {
component: 'my-bom',
releaseType: 'java-yoshi',
versioning: 'dependency-manifest',
},
'multi1/sub1': {
component: 'multi1-sub1',
releaseType: 'java-yoshi',
},
});
const candidates: CandidateReleasePullRequest[] = [
buildMockCandidatePullRequest('multi1/sub1', 'java-yoshi', '2.3.0', {
component: 'multi1-sub1',
updates: [
buildMockPackageUpdate('multi1/pom.xml', 'multi1/pom.xml', '2.3.0'),
],
}),
];
stubFilesFromFixtures({
sandbox,
github,
fixturePath: fixturesPath,
files: ['bom/pom.xml', 'multi1/sub1/pom.xml'],
flatten: false,
targetBranch: 'main',
});
sandbox
.stub(github, 'findFilesByFilenameAndRef')
.withArgs('pom.xml', 'main')
.resolves(['bom/pom.xml', 'multi1/sub1/pom.xml']);
const newCandidates = await plugin.run(candidates);
expect(newCandidates).length(1);
safeSnapshot(newCandidates[0].pullRequest.body.toString());
expect(newCandidates[0].pullRequest.body.releaseData).length(2);
const bomData = newCandidates[0].pullRequest.body.releaseData.find(
data => data.component === 'com.google.example:my-bom'
);
expect(bomData?.version?.toString()).to.eql('1.3.0');
});
});
});

Expand Down

0 comments on commit c3deba7

Please sign in to comment.