-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gerrit): not auto-approving if change already had a Code-Review +1
- Loading branch information
Showing
3 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,10 +393,20 @@ describe('modules/platform/gerrit/client', () => { | |
|
||
describe('approveChange()', () => { | ||
it('already approved - do nothing', async () => { | ||
const change = partial<GerritChange>({}); | ||
const change = partial<GerritChange>({ | ||
labels: { | ||
'Code-Review': { | ||
all: [{ value: 2 }], | ||
}, | ||
}, | ||
}); | ||
httpMock | ||
.scope(gerritEndpointUrl) | ||
.get((url) => url.includes('/a/changes/123456?o=')) | ||
.get( | ||
(url) => | ||
url.includes('/a/changes/123456?o=') && | ||
url.includes('o=DETAILED_LABELS'), | ||
) | ||
.reply(200, gerritRestResponse(change), jsonResultHeader); | ||
await expect(client.approveChange(123456)).toResolve(); | ||
}); | ||
|
@@ -405,14 +415,43 @@ describe('modules/platform/gerrit/client', () => { | |
const change = partial<GerritChange>({ labels: {} }); | ||
httpMock | ||
.scope(gerritEndpointUrl) | ||
.get((url) => url.includes('/a/changes/123456?o=')) | ||
.get( | ||
(url) => | ||
url.includes('/a/changes/123456?o=') && | ||
url.includes('o=DETAILED_LABELS'), | ||
) | ||
.reply(200, gerritRestResponse(change), jsonResultHeader); | ||
|
||
await expect(client.approveChange(123456)).toResolve(); | ||
}); | ||
|
||
it('not already approved - approve now', async () => { | ||
Check failure on line 428 in lib/modules/platform/gerrit/client.spec.ts GitHub Actions / test (7/16)modules/platform/gerrit/client › approveChange() › not already approved - approve now
|
||
const change = partial<GerritChange>({ labels: { 'Code-Review': {} } }); | ||
const change = partial<GerritChange>({ | ||
labels: { 'Code-Review': { all: [] } }, | ||
}); | ||
httpMock | ||
.scope(gerritEndpointUrl) | ||
.get((url) => url.includes('/a/changes/123456?o=')) | ||
.reply(200, gerritRestResponse(change), jsonResultHeader); | ||
const approveMock = httpMock | ||
.scope(gerritEndpointUrl) | ||
.post('/a/changes/123456/revisions/current/review', { | ||
labels: { 'Code-Review': +2 }, | ||
notify: 'NONE', | ||
}) | ||
.reply(200, gerritRestResponse(''), jsonResultHeader); | ||
await expect(client.approveChange(123456)).toResolve(); | ||
Check failure on line 443 in lib/modules/platform/gerrit/client.spec.ts GitHub Actions / test (7/16)modules/platform/gerrit/client › approveChange() › not already approved - approve now
|
||
expect(approveMock.isDone()).toBeTrue(); | ||
}); | ||
|
||
it('not already approved because of +1 - approve now', async () => { | ||
const change = partial<GerritChange>({ | ||
labels: { | ||
'Code-Review': { | ||
all: [{ value: 1 }], | ||
}, | ||
}, | ||
}); | ||
httpMock | ||
.scope(gerritEndpointUrl) | ||
.get((url) => url.includes('/a/changes/123456?o=')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters