mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-06-24 14:58:21 -04:00
feat: update the default comment on error
This commit is contained in:
parent
7c420531c8
commit
8b0412b111
10 changed files with 75 additions and 29 deletions
|
@ -1238,7 +1238,6 @@ describe("cli runner", () => {
|
|||
|
||||
test("with multiple target branches, one failure and error notification enabled", async () => {
|
||||
jest.spyOn(GitHubClient.prototype, "createPullRequest").mockImplementation((backport: BackportPullRequest) => {
|
||||
|
||||
throw new Error(`Mocked error: ${backport.base}`);
|
||||
});
|
||||
|
||||
|
@ -1323,9 +1322,9 @@ describe("cli runner", () => {
|
|||
});
|
||||
expect(GitHubClient.prototype.createPullRequest).toThrowError();
|
||||
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledTimes(3);
|
||||
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledWith("https://api.github.com/repos/owner/reponame/pulls/2368", "Backporting failed: Error: Mocked error: v1");
|
||||
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledWith("https://api.github.com/repos/owner/reponame/pulls/2368", "Backporting failed: Error: Mocked error: v2");
|
||||
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledWith("https://api.github.com/repos/owner/reponame/pulls/2368", "Backporting failed: Error: Mocked error: v3");
|
||||
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledWith("https://api.github.com/repos/owner/reponame/pulls/2368", "The backport to `v1` failed. Check the latest run for more details.");
|
||||
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledWith("https://api.github.com/repos/owner/reponame/pulls/2368", "The backport to `v2` failed. Check the latest run for more details.");
|
||||
expect(GitHubClient.prototype.createPullRequestComment).toBeCalledWith("https://api.github.com/repos/owner/reponame/pulls/2368", "The backport to `v3` failed. Check the latest run for more details.");
|
||||
});
|
||||
|
||||
test("with some failures and dry run enabled", async () => {
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
import { injectError } from "@bp/service/runner/runner-util";
|
||||
import { injectError, injectTargetBranch } from "@bp/service/runner/runner-util";
|
||||
|
||||
describe("check runner utilities", () => {
|
||||
test("properly inject error message", () => {
|
||||
expect(injectError("Original message: {{error}}", "to inject")).toStrictEqual("Original message: to inject");
|
||||
});
|
||||
|
||||
test("missing placeholder in the original message", () => {
|
||||
test("missing error placeholder in the original message", () => {
|
||||
expect(injectError("Original message: {{wrong}}", "to inject")).toStrictEqual("Original message: {{wrong}}");
|
||||
});
|
||||
|
||||
test("properly inject target branch into message", () => {
|
||||
expect(injectTargetBranch("Original message: {{target-branch}}", "to inject")).toStrictEqual("Original message: to inject");
|
||||
});
|
||||
|
||||
test("missing target branch placeholder in the original message", () => {
|
||||
expect(injectTargetBranch("Original message: {{wrong}}", "to inject")).toStrictEqual("Original message: {{wrong}}");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue