Skip to content

Commit

Permalink
feat(gha): name update
Browse files Browse the repository at this point in the history
  • Loading branch information
akshit9738 committed Oct 4, 2024
1 parent 46f0c85 commit acfb835
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inputs:
github-app:
description: 'BrowserStack Github App'
required: false
default: 'browserstack[bot]'
default: 'browserstack-integrations[bot]'
runs:
using: 'node20'
main: 'dist/index.js'
9 changes: 5 additions & 4 deletions setup-env/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9597,18 +9597,19 @@ class InputValidator {

/**
* Validates the app name input to ensure it is a valid non-empty string.
* If the input is 'none' or not provided, it returns 'browserstack[bot]'.
* If the input is 'none' or not provided, it returns 'browserstack-integrations[bot]'.
* @param {string} githubAppName Input for 'github-app'
* @returns {string} Validated app name, or 'browserstack[bot]' if input is 'none' or invalid
* @returns {string} Validated app name, or 'browserstack-integrations[bot]'
* if input is 'none' or invalid
* @throws {Error} If the input is not a valid non-empty string
*/
static validateGithubAppName(githubAppName) {
if (typeof githubAppName !== 'string') {
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
}

if (githubAppName.toLowerCase() === 'browserstack[bot]') {
return 'browserstack[bot]';
if (githubAppName.toLowerCase() === 'browserstack-integrations[bot]') {
return 'browserstack-integrations[bot]';
}

if (githubAppName.trim().length > 0) {
Expand Down
9 changes: 5 additions & 4 deletions setup-env/src/actionInput/inputValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,19 @@ class InputValidator {

/**
* Validates the app name input to ensure it is a valid non-empty string.
* If the input is 'none' or not provided, it returns 'browserstack[bot]'.
* If the input is 'none' or not provided, it returns 'browserstack-integrations[bot]'.
* @param {string} githubAppName Input for 'github-app'
* @returns {string} Validated app name, or 'browserstack[bot]' if input is 'none' or invalid
* @returns {string} Validated app name, or 'browserstack-integrations[bot]'
* if input is 'none' or invalid
* @throws {Error} If the input is not a valid non-empty string
*/
static validateGithubAppName(githubAppName) {
if (typeof githubAppName !== 'string') {
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
}

if (githubAppName.toLowerCase() === 'browserstack[bot]') {
return 'browserstack[bot]';
if (githubAppName.toLowerCase() === 'browserstack-integrations[bot]') {
return 'browserstack-integrations[bot]';
}

if (githubAppName.trim().length > 0) {
Expand Down
8 changes: 4 additions & 4 deletions setup-env/test/actionInput/inputValidator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ describe('InputValidator class to validate individual fields of the action input
});

context('Validates GitHub App Name', () => {
it("Returns 'browserstack[bot]' if the app name is not provided", () => {
it("Returns 'browserstack-integrations[bot]' if the app name is not provided", () => {
expect(() => InputValidator.validateGithubAppName()).to.throw("Invalid input for 'github-app'. Must be a valid string.");
});

it("Returns 'browserstack[bot]' if the app name is 'browserstack[bot]' (case insensitive)", () => {
expect(InputValidator.validateGithubAppName('BrowserStack[BOT]')).to.eq('browserstack[bot]');
it("Returns 'browserstack-integrations[bot]' if the app name is 'browserstack-integrations[bot]' (case insensitive)", () => {
expect(InputValidator.validateGithubAppName('BrowserStack-integrations[BOT]')).to.eq('browserstack-integrations[bot]');
});

it('Throws an error if the app name is an empty string', () => {
Expand All @@ -170,7 +170,7 @@ describe('InputValidator class to validate individual fields of the action input
expect(() => InputValidator.validateGithubAppName(123)).to.throw("Invalid input for 'github-app'. Must be a valid string.");
});

it('Returns the app name if it is a valid non-empty string and not "browserstack[bot]"', () => {
it('Returns the app name if it is a valid non-empty string and not "browserstack-integrations[bot]"', () => {
const validAppName = 'someValidAppName';
expect(InputValidator.validateGithubAppName(validAppName)).to.eq(validAppName);
});
Expand Down

0 comments on commit acfb835

Please sign in to comment.