Skip to content

Commit 35112f6

Browse files
committed
refactor: validate username method name. modify: comments
1 parent d12356d commit 35112f6

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

setup-env/dist/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ class InputValidator {
597597
* 1. Push
598598
* 2. Pull Request
599599
* 3. Release
600+
* 4. Other events
600601
* @returns {String} Metadata
601602
*/
602603
static _getBuildInfo() {
@@ -665,7 +666,7 @@ class InputValidator {
665666
* @param {String} inputUsername BrowserStack Username
666667
* @returns {String} Modified Username
667668
*/
668-
static validateUsername(inputUsername) {
669+
static updateUsername(inputUsername) {
669670
return `${inputUsername}-GitHubAction`;
670671
}
671672

@@ -4297,9 +4298,7 @@ const ActionInput = __webpack_require__(972);
42974298
/**
42984299
* Entry point to initiate the Action.
42994300
* 1. Triggers parsing of action input values
4300-
* 2. Decides requirement of Local Binary
4301-
* 3. Start/Stop Local Binary if required
4302-
* 4. Triggers uploading of artifacts
4301+
* 2. Sets the environment variables required for BrowserStack
43034302
*/
43044303
const run = async () => {
43054304
try {
@@ -6103,11 +6102,10 @@ class ActionInput {
61036102
}
61046103

61056104
/**
6106-
* Triggers conditional validation of action input values based on the operation
6107-
* to be performed, i.e. start/no local connection required, stopping of local connection
6105+
* Validates the input values
61086106
*/
61096107
_validateInput() {
6110-
this.username = InputValidator.validateUsername(this.username);
6108+
this.username = InputValidator.updateUsername(this.username);
61116109
this.buildName = InputValidator.validateBuildName(this.buildName);
61126110
this.projectName = InputValidator.validateProjectName(this.projectName);
61136111
}
@@ -6119,7 +6117,10 @@ class ActionInput {
61196117
core.startGroup('Setting Environment Variables');
61206118

61216119
core.exportVariable(ENV_VARS.BROWSERSTACK_USERNAME, this.username);
6120+
core.info(`Use ${ENV_VARS.BROWSERSTACK_USERNAME} environment variable for your username in your tests\n`);
6121+
61226122
core.exportVariable(ENV_VARS.BROWSERSTACK_ACCESS_KEY, this.accessKey);
6123+
core.info(`Use ${ENV_VARS.BROWSERSTACK_ACCESS_KEY} environment variable for your access key in your tests\n`);
61236124

61246125
core.exportVariable(ENV_VARS.BROWSERSTACK_PROJECT_NAME, this.projectName);
61256126
core.info(`${ENV_VARS.BROWSERSTACK_PROJECT_NAME} environment variable set as: ${this.projectName}`);

setup-env/src/actionInput/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ class ActionInput {
3636
}
3737

3838
/**
39-
* Triggers conditional validation of action input values based on the operation
40-
* to be performed, i.e. start/no local connection required, stopping of local connection
39+
* Validates the input values
4140
*/
4241
_validateInput() {
43-
this.username = InputValidator.validateUsername(this.username);
42+
this.username = InputValidator.updateUsername(this.username);
4443
this.buildName = InputValidator.validateBuildName(this.buildName);
4544
this.projectName = InputValidator.validateProjectName(this.projectName);
4645
}
@@ -52,7 +51,10 @@ class ActionInput {
5251
core.startGroup('Setting Environment Variables');
5352

5453
core.exportVariable(ENV_VARS.BROWSERSTACK_USERNAME, this.username);
54+
core.info(`Use ${ENV_VARS.BROWSERSTACK_USERNAME} environment variable for your username in your tests\n`);
55+
5556
core.exportVariable(ENV_VARS.BROWSERSTACK_ACCESS_KEY, this.accessKey);
57+
core.info(`Use ${ENV_VARS.BROWSERSTACK_ACCESS_KEY} environment variable for your access key in your tests\n`);
5658

5759
core.exportVariable(ENV_VARS.BROWSERSTACK_PROJECT_NAME, this.projectName);
5860
core.info(`${ENV_VARS.BROWSERSTACK_PROJECT_NAME} environment variable set as: ${this.projectName}`);

setup-env/src/actionInput/inputValidator.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class InputValidator {
1111
* 1. Push
1212
* 2. Pull Request
1313
* 3. Release
14+
* 4. Other events
1415
* @returns {String} Metadata
1516
*/
1617
static _getBuildInfo() {
@@ -79,7 +80,7 @@ class InputValidator {
7980
* @param {String} inputUsername BrowserStack Username
8081
* @returns {String} Modified Username
8182
*/
82-
static validateUsername(inputUsername) {
83+
static updateUsername(inputUsername) {
8384
return `${inputUsername}-GitHubAction`;
8485
}
8586

setup-env/src/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ const ActionInput = require('./actionInput');
44
/**
55
* Entry point to initiate the Action.
66
* 1. Triggers parsing of action input values
7-
* 2. Decides requirement of Local Binary
8-
* 3. Start/Stop Local Binary if required
9-
* 4. Triggers uploading of artifacts
7+
* 2. Sets the environment variables required for BrowserStack
108
*/
119
const run = async () => {
1210
try {

setup-env/test/actionInput/index.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ describe('Action Input operations for fetching all inputs, triggering validation
1616

1717
beforeEach(() => {
1818
stubbedInput = sinon.stub(core, 'getInput');
19-
sinon.stub(InputValidator, 'validateUsername').returns('validatedUsername');
19+
sinon.stub(InputValidator, 'updateUsername').returns('validatedUsername');
2020
sinon.stub(InputValidator, 'validateBuildName').returns('validatedBuildName');
2121
sinon.stub(InputValidator, 'validateProjectName').returns('validatedProjectName');
2222
});
2323

2424
afterEach(() => {
2525
core.getInput.restore();
26-
InputValidator.validateUsername.restore();
26+
InputValidator.updateUsername.restore();
2727
InputValidator.validateBuildName.restore();
2828
InputValidator.validateProjectName.restore();
2929
});
@@ -38,7 +38,7 @@ describe('Action Input operations for fetching all inputs, triggering validation
3838
sinon.assert.calledWith(core.getInput, INPUT.ACCESS_KEY, { required: true });
3939
sinon.assert.calledWith(core.getInput, INPUT.BUILD_NAME);
4040
sinon.assert.calledWith(core.getInput, INPUT.PROJECT_NAME);
41-
sinon.assert.calledWith(InputValidator.validateUsername, 'someUsername');
41+
sinon.assert.calledWith(InputValidator.updateUsername, 'someUsername');
4242
sinon.assert.calledWith(InputValidator.validateBuildName, 'someBuildName');
4343
sinon.assert.calledWith(InputValidator.validateProjectName, 'someProjectName');
4444
expect(actionInput.username).to.eq('validatedUsername');
@@ -54,7 +54,7 @@ describe('Action Input operations for fetching all inputs, triggering validation
5454
} catch (e) {
5555
expect(e.message).to.eq('Action input failed for reason: Username Required');
5656
}
57-
sinon.assert.notCalled(InputValidator.validateUsername);
57+
sinon.assert.notCalled(InputValidator.updateUsername);
5858
sinon.assert.notCalled(InputValidator.validateBuildName);
5959
sinon.assert.notCalled(InputValidator.validateProjectName);
6060
});
@@ -67,7 +67,7 @@ describe('Action Input operations for fetching all inputs, triggering validation
6767
} catch (e) {
6868
expect(e.message).to.eq('Action input failed for reason: Access Key Required');
6969
}
70-
sinon.assert.notCalled(InputValidator.validateUsername);
70+
sinon.assert.notCalled(InputValidator.updateUsername);
7171
sinon.assert.notCalled(InputValidator.validateBuildName);
7272
sinon.assert.notCalled(InputValidator.validateProjectName);
7373
});

setup-env/test/actionInput/inputValidator.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('InputValidator class to validate individual fields of the action input
88
context('Validates Username', () => {
99
it("Returns the username with '-GitHubAction' suffix", () => {
1010
const inputUsername = 'someUsername';
11-
expect(InputValidator.validateUsername(inputUsername)).to.eq(`${inputUsername}-GitHubAction`);
11+
expect(InputValidator.updateUsername(inputUsername)).to.eq(`${inputUsername}-GitHubAction`);
1212
});
1313
});
1414

0 commit comments

Comments
 (0)