mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-06-27 21:23:48 +00:00
feat: pull request backporting
feat: backport still open pull requests
This commit is contained in:
commit
b3936e019a
53 changed files with 48467 additions and 0 deletions
1816
test/support/moctokit/moctokit-data.ts
Normal file
1816
test/support/moctokit/moctokit-data.ts
Normal file
File diff suppressed because it is too large
Load diff
89
test/support/moctokit/moctokit-support.ts
Normal file
89
test/support/moctokit/moctokit-support.ts
Normal file
|
@ -0,0 +1,89 @@
|
|||
import LoggerServiceFactory from "@bp/service/logger/logger-service-factory";
|
||||
import { Moctokit } from "@kie/mock-github";
|
||||
import { targetOwner, repo, mergedPullRequestFixture, openPullRequestFixture, notMergedPullRequestFixture, notFoundPullRequestNumber, sameOwnerPullRequestFixture } from "./moctokit-data";
|
||||
|
||||
const logger = LoggerServiceFactory.getLogger();
|
||||
|
||||
export const setupMoctokit = (): Moctokit => {
|
||||
logger.debug("Setting up moctokit.");
|
||||
|
||||
const mock = new Moctokit();
|
||||
|
||||
// setup the mock requests here
|
||||
|
||||
// valid requests
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: mergedPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: mergedPullRequestFixture
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: sameOwnerPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: sameOwnerPullRequestFixture
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: openPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: openPullRequestFixture
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: notMergedPullRequestFixture.number
|
||||
})
|
||||
.reply({
|
||||
status: 200,
|
||||
data: notMergedPullRequestFixture
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.create()
|
||||
.reply({
|
||||
status: 201,
|
||||
data: mergedPullRequestFixture
|
||||
});
|
||||
|
||||
mock.rest.pulls
|
||||
.requestReviewers()
|
||||
.reply({
|
||||
status: 201,
|
||||
data: mergedPullRequestFixture
|
||||
});
|
||||
|
||||
|
||||
// invalid requests
|
||||
mock.rest.pulls
|
||||
.get({
|
||||
owner: targetOwner,
|
||||
repo: repo,
|
||||
pull_number: notFoundPullRequestNumber
|
||||
})
|
||||
.reply({
|
||||
status: 404,
|
||||
data: {
|
||||
message: "Not found"
|
||||
}
|
||||
});
|
||||
|
||||
return mock;
|
||||
};
|
17
test/support/utils.ts
Normal file
17
test/support/utils.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import * as core from "@actions/core";
|
||||
|
||||
export const addProcessArgs = (args: string[]) => {
|
||||
process.argv = [...process.argv, ...args];
|
||||
};
|
||||
|
||||
export const resetProcessArgs = () => {
|
||||
process.argv = ["node", "backporting"];
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const spyGetInput = (obj: any) => {
|
||||
const mock = jest.spyOn(core, "getInput");
|
||||
mock.mockImplementation((name: string) : string => {
|
||||
return obj[name];
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue