mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-06-28 13:43:48 +00:00
feat: integrate tool with gitlab service (#39)
* feat: integrate tool with gitlab service Fix https://github.com/lampajr/backporting/issues/30
This commit is contained in:
parent
8a007941d1
commit
107f5e52d6
35 changed files with 17821 additions and 1553 deletions
41
test/service/git/github/github-client.test.ts
Normal file
41
test/service/git/github/github-client.test.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
import GitClientFactory from "@bp/service/git/git-client-factory";
|
||||
import { GitPullRequest, GitClientType } from "@bp/service/git/git.types";
|
||||
import GitHubClient from "@bp/service/git/github/github-client";
|
||||
import { mergedPullRequestFixture, repo, targetOwner } from "../../../support/mock/github-data";
|
||||
import { mockGitHubClient } from "../../../support/mock/git-client-mock-support";
|
||||
|
||||
describe("github service", () => {
|
||||
|
||||
let gitClient: GitHubClient;
|
||||
|
||||
beforeAll(() => {
|
||||
// init git service
|
||||
GitClientFactory.reset();
|
||||
GitClientFactory.getOrCreate(GitClientType.GITHUB, "whatever", "http://localhost/api/v3");
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// mock github api calls
|
||||
mockGitHubClient("http://localhost/api/v3");
|
||||
|
||||
gitClient = GitClientFactory.getClient() as GitHubClient;
|
||||
});
|
||||
|
||||
test("get pull request: success", async () => {
|
||||
const res: GitPullRequest = await gitClient.getPullRequest(targetOwner, repo, mergedPullRequestFixture.number);
|
||||
expect(res.sourceRepo).toEqual({
|
||||
owner: "fork",
|
||||
project: "reponame",
|
||||
cloneUrl: "https://github.com/fork/reponame.git"
|
||||
});
|
||||
expect(res.targetRepo).toEqual({
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
cloneUrl: "https://github.com/owner/reponame.git"
|
||||
});
|
||||
expect(res.title).toBe("PR Title");
|
||||
expect(res.commits!.length).toBe(1);
|
||||
expect(res.commits).toEqual(["28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"]);
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue