mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-13 09:09:13 -04: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
37
test/service/git/git-util.test.ts
Normal file
37
test/service/git/git-util.test.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { inferGitApiUrl, inferGitClient } from "@bp/service/git/git-util";
|
||||
import { GitClientType } from "@bp/service/git/git.types";
|
||||
|
||||
describe("check git utilities", () => {
|
||||
|
||||
test("check infer gitlab api", ()=> {
|
||||
expect(inferGitApiUrl("https://my.gitlab.awesome.com/superuser/backporting-example/-/merge_requests/4")).toStrictEqual("https://my.gitlab.awesome.com/api/v4");
|
||||
});
|
||||
|
||||
test("check infer gitlab api with different version", ()=> {
|
||||
expect(inferGitApiUrl("http://my.gitlab.awesome.com/superuser/backporting-example/-/merge_requests/4", "v2")).toStrictEqual("http://my.gitlab.awesome.com/api/v2");
|
||||
});
|
||||
|
||||
test("check infer github api", ()=> {
|
||||
expect(inferGitApiUrl("https://github.com/superuser/backporting-example/pull/4")).toStrictEqual("https://api.github.com");
|
||||
});
|
||||
|
||||
test("check infer custom github api", ()=> {
|
||||
expect(inferGitApiUrl("http://github.acme-inc.com/superuser/backporting-example/pull/4")).toStrictEqual("http://github.acme-inc.com/api/v4");
|
||||
});
|
||||
|
||||
test("check infer custom github api with different version", ()=> {
|
||||
expect(inferGitApiUrl("http://github.acme-inc.com/superuser/backporting-example/pull/4", "v3")).toStrictEqual("http://github.acme-inc.com/api/v3");
|
||||
});
|
||||
|
||||
test("check infer github client", ()=> {
|
||||
expect(inferGitClient("https://github.com/superuser/backporting-example/-/merge_requests/4")).toStrictEqual(GitClientType.GITHUB);
|
||||
});
|
||||
|
||||
test("check infer gitlab client", ()=> {
|
||||
expect(inferGitClient("https://my.gitlab.awesome.com/superuser/backporting-example/-/merge_requests/4")).toStrictEqual(GitClientType.GITLAB);
|
||||
});
|
||||
|
||||
test("Not recognized git client type", ()=> {
|
||||
expect(() => inferGitClient("https://not.recognized/superuser/backporting-example/-/merge_requests/4")).toThrowError("Remote git service not recognized from pr url: https://not.recognized/superuser/backporting-example/-/merge_requests/4");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue