Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: failing test for respecting versioning strategy #1797

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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