Skip to content

Commit ea7c4c6

Browse files
committed
test fixes
1 parent d121bfc commit ea7c4c6

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

lib/LocalBinary.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ function LocalBinary(){
2424
return this.sourceURL;
2525
}
2626

27-
if (process.env.BINARY_DOWNLOAD_SOURCE_URL !== undefined && process.env.BINARY_DOWNLOAD_FALLBACK_ENABLED == "true" && this.parentRetries != 4) {
27+
if (process.env.BINARY_DOWNLOAD_SOURCE_URL !== undefined && process.env.BINARY_DOWNLOAD_FALLBACK_ENABLED == 'true' && this.parentRetries != 4) {
2828
/* This is triggered from Local.js if there's an error executing the downloaded binary */
2929
return process.env.BINARY_DOWNLOAD_SOURCE_URL;
3030
}
31-
31+
3232
let cmd, opts;
3333
cmd = 'node';
3434
opts = [path.join(__dirname, 'fetchDownloadSourceUrl.js'), this.key];
35-
36-
if (retries == 4 || (process.env.BINARY_DOWNLOAD_FALLBACK_ENABLED == "true" && this.parentRetries == 4)) {
35+
36+
if (retries == 4 || (process.env.BINARY_DOWNLOAD_FALLBACK_ENABLED == 'true' && this.parentRetries == 4)) {
3737
opts.push(true, this.downloadErrorMessage || process.env.BINARY_DOWNLOAD_ERROR_MESSAGE);
3838
} else {
3939
opts.push(false, null);
@@ -47,7 +47,7 @@ function LocalBinary(){
4747
} else if (conf.useCaCertificate) {
4848
opts.push(undefined, undefined, conf.useCaCertificate);
4949
}
50-
50+
5151
const userAgent = [packageName, version].join('/');
5252
const env = Object.assign({ 'USER_AGENT': userAgent }, process.env);
5353
const obj = childProcess.spawnSync(cmd, opts, { env: env });
@@ -59,7 +59,7 @@ function LocalBinary(){
5959
let output = Buffer.from(JSON.parse(JSON.stringify(obj.stderr)).data).toString();
6060
throw(output);
6161
}
62-
}
62+
};
6363

6464
this.getDownloadPath = function (conf, retries) {
6565
let sourceURL = this.getSourceUrl(conf, retries) + '/';
@@ -91,8 +91,8 @@ function LocalBinary(){
9191

9292
this.binaryDownloadError = function(errorMessagePrefix, errorMessage) {
9393
console.error(errorMessagePrefix, errorMessage);
94-
this.downloadErrorMessage = errorMessagePrefix + " : " + errorMessage;
95-
}
94+
this.downloadErrorMessage = errorMessagePrefix + ' : ' + errorMessage;
95+
};
9696

9797
this.retryBinaryDownload = function(conf, destParentDir, callback, retries, binaryPath) {
9898
var that = this;
@@ -118,7 +118,7 @@ function LocalBinary(){
118118
} catch (e) {
119119
return console.error(`Unable to fetch the source url to download the binary with error: ${e}`);
120120
}
121-
121+
122122
console.log('Downloading in sync');
123123
var that = this;
124124
if(!this.checkPath(destParentDir))
@@ -169,7 +169,7 @@ function LocalBinary(){
169169
} catch (e) {
170170
return console.error(`Unable to fetch the source url to download the binary with error: ${e}`);
171171
}
172-
172+
173173
var that = this;
174174
if(!this.checkPath(destParentDir))
175175
fs.mkdirSync(destParentDir);

lib/fetchDownloadSourceUrl.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const https = require('https'),
44

55
const authToken = process.argv[2], proxyHost = process.argv[5], proxyPort = process.argv[6], useCaCertificate = process.argv[7], downloadFallback = process.argv[3], downloadErrorMessage = process.argv[4];
66

7-
let body = '', data = {"auth_token": authToken};
7+
let body = '', data = {'auth_token': authToken};
88
const options = {
9-
hostname: 'local.browserstack.com',
9+
// hostname: 'local.browserstack.com',
10+
hostname: 'k8s-devlocal.bsstag.com',
1011
port: 443,
1112
path: '/binary/api/v1/endpoint',
1213
method: 'POST',
@@ -15,9 +16,9 @@ const options = {
1516
'user-agent': process.env.USER_AGENT
1617
}
1718
};
18-
if (downloadFallback == "true") {
19+
if (downloadFallback == 'true') {
1920
options.headers['X-Local-Fallback-Cloudflare'] = true;
20-
data["error_message"] = downloadErrorMessage;
21+
data['error_message'] = downloadErrorMessage;
2122
}
2223

2324
if(proxyHost && proxyPort) {
@@ -51,7 +52,7 @@ const req = https.request(options, res => {
5152
});
5253
res.on('error', (err) => {
5354
console.error(err);
54-
})
55+
});
5556
});
5657
req.on('error', e => {
5758
console.error(e);

test/local.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ describe('LocalBinary', function () {
280280
// ensure that we have a valid binary downloaded
281281

282282
// removeIfInvalid();
283-
(new LocalBinary()).binaryPath({}, 'abc', function(binaryPath) {
283+
(new LocalBinary()).binaryPath({}, 'abc', 9, function(binaryPath) {
284284
defaultBinaryPath = binaryPath;
285285
tempfs.mkdir({
286286
recursive: true
@@ -313,7 +313,7 @@ describe('LocalBinary', function () {
313313
fs.writeFile(defaultBinaryPath, 'Random String', function() {
314314
fs.chmod(defaultBinaryPath, '0755', function() {
315315
localBinary.binaryPath({
316-
}, 'abc', function(binaryPath) {
316+
}, 'abc', 9, function(binaryPath) {
317317
expect(downloadStub.called).to.be.true;
318318
done();
319319
});
@@ -331,7 +331,7 @@ describe('LocalBinary', function () {
331331
});
332332

333333
localBinary.binaryPath({
334-
}, 'abc', function(binaryPath) {
334+
}, 'abc', 9, function(binaryPath) {
335335
expect(downloadStub.called).to.be.true;
336336
done();
337337
});

0 commit comments

Comments
 (0)