-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update the default comment on error
- Loading branch information
Showing
10 changed files
with
75 additions
and
29 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { MESSAGE_ERROR_PLACEHOLDER } from "@bp/service/configs/configs.types"; | ||
import { MESSAGE_ERROR_PLACEHOLDER, MESSAGE_TARGET_BRANCH_PLACEHOLDER } from "@bp/service/configs/configs.types"; | ||
|
||
/** | ||
* Inject the error message in the provided `message`. | ||
* This is inject in place of the MESSAGE_ERROR_PLACEHOLDER placeholder | ||
* This is injected in place of the MESSAGE_ERROR_PLACEHOLDER placeholder | ||
* @param message string that needs to be updated | ||
* @param errMsg the error message that needs to be injected | ||
*/ | ||
export const injectError = (message: string, errMsg: string): string => { | ||
return message.replace(MESSAGE_ERROR_PLACEHOLDER, errMsg); | ||
}; | ||
|
||
/** | ||
* Inject the target branch into the provided `message`. | ||
* This is injected in place of the MESSAGE_TARGET_BRANCH_PLACEHOLDER placeholder | ||
* @param message string that needs to be updated | ||
* @param targetBranch the target branch to inject | ||
* @returns | ||
*/ | ||
export const injectTargetBranch = (message: string, targetBranch: string): string => { | ||
return message.replace(MESSAGE_TARGET_BRANCH_PLACEHOLDER, targetBranch); | ||
}; |
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
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
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 |
---|---|---|
@@ -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}}"); | ||
}); | ||
}); |