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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: failing test for manifest with mixed includeComponentInTag #2220

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/fixtures/release-notes/multiple-with-no-component.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
:robot: I have created a release \*beep\* \*boop\*
---
<details><summary>3.2.7</summary>

### [3.2.7](https://www.github.com/googleapis/java-asset/compare/v3.2.6...v3.2.7) (2021-10-20)


### Dependencies

* update dependency com.google.api.grpc:proto-google-cloud-orgpolicy-v1 to v2.0.6 ([#980](https://www.github.com/googleapis/java-asset/issues/980)) ([710bb59](https://www.github.com/googleapis/java-asset/commit/710bb59c17da57f1104a84f8e44ada7c7fc9a59f))
* update dependency com.google.api.grpc:proto-google-cloud-os-config-v1 to v2.2.2 ([#981](https://www.github.com/googleapis/java-asset/issues/981)) ([5495310](https://www.github.com/googleapis/java-asset/commit/5495310b7abf3a3dfa6878fc20e12ac3f268c93f))
</details>
<details><summary>bar: 1.0.1</summary>


### [1.0.1](https://www.github.com/googleapis/java-asset/compare/bar-v1.0.0...vbar-v1.0.1) (2021-10-20)


### Dependencies

* update dependency com.google.api.grpc:proto-google-cloud-orgpolicy-v1 to v2.0.6 ([#980](https://www.github.com/googleapis/java-asset/issues/980)) ([710bb59](https://www.github.com/googleapis/java-asset/commit/710bb59c17da57f1104a84f8e44ada7c7fc9a59f))
* update dependency com.google.api.grpc:proto-google-cloud-os-config-v1 to v2.2.2 ([#981](https://www.github.com/googleapis/java-asset/issues/981)) ([5495310](https://www.github.com/googleapis/java-asset/commit/5495310b7abf3a3dfa6878fc20e12ac3f268c93f))
</details>


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
3 changes: 2 additions & 1 deletion test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {CompositeUpdater} from '../src/updaters/composite';
import {PullRequestOverflowHandler} from '../src/util/pull-request-overflow-handler';
import {ReleasePullRequest} from '../src/release-pull-request';
import {PullRequest} from '../src/pull-request';
import {FileNotFoundError} from '../src/errors';

export function stubSuggesterWithSnapshot(
sandbox: sinon.SinonSandbox,
Expand Down Expand Up @@ -236,7 +237,7 @@ export function stubFilesFromFixtures(options: StubFiles) {
for (const [file, content] of inlineFiles) {
stub.withArgs(file, targetBranch).resolves(buildGitHubFileRaw(content));
}
stub.rejects(Object.assign(Error('not found'), {status: 404}));
stub.rejects(new FileNotFoundError('somepath'));
}

// get list of files in a directory
Expand Down
142 changes: 142 additions & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
mockTags,
assertNoHasUpdate,
mockReleaseData,
stubFilesFromFixtures,
} from './helpers';
import {expect} from 'chai';
import * as assert from 'assert';
Expand Down Expand Up @@ -5519,6 +5520,147 @@ describe('Manifest', () => {
expect(releases[3].path).to.eql('packages/datastore-lock');
expect(releases[3].name).to.eql('datastore-lock: v2.1.0');
});

it('should handle skipped component in single manifest PR', async () => {
mockPullRequests(
github,
[],
[
{
headBranchName: 'release-please--branches--main--components--foo',
baseBranchName: 'main',
number: 1234,
title: 'chore: release main',
body: pullRequestBody('release-notes/single.txt'),
labels: ['autorelease: pending'],
files: [],
sha: 'abc123',
},
]
);
stubFilesFromFixtures({
sandbox,
github,
targetBranch: 'main',
fixturePath: 'unused',
files: [],
inlineFiles: [
[
'foo/package.json',
'{"name": "@namespace/foo", "version": "3.2.6"}',
],
[
'bar/package.json',
'{"name": "@namespace/bar", "version": "1.0.0"}',
],
],
});
const manifest = new Manifest(
github,
'main',
{
foo: {
releaseType: 'node',
includeComponentInTag: false,
},
bar: {
releaseType: 'node',
includeComponentInTag: true,
},
},
{
foo: Version.parse('3.2.6'),
bar: Version.parse('1.0.0'),
}
);
const releases = await manifest.buildReleases();
expect(releases).lengthOf(1);
expect(releases[0].tag.toString()).to.eql('v3.2.7');
expect(releases[0].sha).to.eql('abc123');
expect(releases[0].notes)
.to.be.a('string')
.and.satisfy((msg: string) => msg.startsWith('### [3.2.7]'));
expect(releases[0].path).to.eql('foo');
expect(releases[0].name).to.eql('v3.2.7');
expect(releases[0].draft).to.be.undefined;
expect(releases[0].prerelease).to.be.undefined;
});

it('should handle skipped component in multiple manifest PR', async () => {
mockPullRequests(
github,
[],
[
{
headBranchName: 'release-please--branches--main',
baseBranchName: 'main',
number: 1234,
title: 'chore: release main',
body: pullRequestBody(
'release-notes/multiple-with-no-component.txt'
),
labels: ['autorelease: pending'],
files: [],
sha: 'abc123',
},
]
);
stubFilesFromFixtures({
sandbox,
github,
targetBranch: 'main',
fixturePath: 'unused',
files: [],
inlineFiles: [
[
'foo/package.json',
'{"name": "@namespace/foo", "version": "3.2.6"}',
],
[
'bar/package.json',
'{"name": "@namespace/bar", "version": "1.0.0"}',
],
],
});
const manifest = new Manifest(
github,
'main',
{
foo: {
releaseType: 'node',
includeComponentInTag: false,
},
bar: {
releaseType: 'node',
includeComponentInTag: true,
},
},
{
foo: Version.parse('3.2.6'),
bar: Version.parse('1.0.0'),
}
);
const releases = await manifest.buildReleases();
expect(releases).lengthOf(2);
expect(releases[0].tag.toString()).to.eql('v3.2.7');
expect(releases[0].sha).to.eql('abc123');
expect(releases[0].notes)
.to.be.a('string')
.and.satisfy((msg: string) => msg.startsWith('### [3.2.7]'));
expect(releases[0].path).to.eql('foo');
expect(releases[0].name).to.eql('v3.2.7');
expect(releases[0].draft).to.be.undefined;
expect(releases[0].prerelease).to.be.undefined;
expect(releases[1].tag.toString()).to.eql('bar-v1.0.1');
expect(releases[1].sha).to.eql('abc123');
expect(releases[1].notes)
.to.be.a('string')
.and.satisfy((msg: string) => msg.startsWith('### [1.0.1]'));
expect(releases[1].path).to.eql('bar');
expect(releases[1].name).to.eql('bar: v1.0.1');
expect(releases[1].draft).to.be.undefined;
expect(releases[1].prerelease).to.be.undefined;
});
});

describe('createReleases', () => {
Expand Down
Loading