Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bad requests causing unit tests to hang #478

Merged
merged 4 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/CorrelationIdManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CorrelationIdManager {
}
delete CorrelationIdManager.pendingLookups[appIdUrlString];
});
} else if (res.statusCode >= 400 && res.statusCode < 500) {
} else if (res.statusCode >= 400 && res.statusCode < 500 || res.statusCode === undefined) {
markwolff marked this conversation as resolved.
Show resolved Hide resolved
// Not found, probably a bad key. Do not try again.
CorrelationIdManager.completedLookups[appIdUrlString] = undefined;
delete CorrelationIdManager.pendingLookups[appIdUrlString];
Expand Down
10 changes: 10 additions & 0 deletions Tests/Library/Config.tests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import assert = require("assert");
import sinon = require("sinon");
var http = require("http");
var https = require("https");

import Config = require("../../Library/Config");

Expand All @@ -9,6 +11,14 @@ describe("Library/Config", () => {
var appVer = "appVer";

describe("#constructor(iKey)", () => {
beforeEach(()=> {
sinon.stub(http, 'request');
sinon.stub(https, 'request');
});
afterEach(() => {
http.request.restore();
https.request.restore();
})
it("should throw if no iKey is available", () => {
var env = {};
var originalEnv = process.env;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Library/Util.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ describe("Library/Util", () => {
if (process.env.hasOwnProperty('no_proxy')) {
delete process.env.no_proxy;
}
sinon.spy(http, 'request');
sinon.spy(https, 'request');
sinon.stub(http, 'request');
sinon.stub(https, 'request');
});

afterEach(() => {
Expand Down
77 changes: 42 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@
"prepublishOnly": "npm run build",
"pretest": "npm run build",
"test": "npm run test:ts && npm run test:js",
"test:ts": "mocha ./out/Tests --recursive",
"test:js": "mocha ./Tests/js --recursive",
"test:ts": "mocha ./out/Tests --recursive --no-exit",
"test:js": "mocha ./Tests/js --recursive --no-exit",
"functionaltest": "npm run build && npm pack && node --use_strict ./Tests/FunctionalTests/RunFunctionalTests.js",
"backcompattest": "npm run build && npm pack && node --use_strict ./Tests/BackCompatibility/RunBackCompatTests.js"
},
"devDependencies": {
"@types/cls-hooked": "^4.2.1",
"@types/mocha": "2.2.40",
"@types/mocha": "2.2.48",
"@types/node": "4.2.4",
"@types/sinon": "2.1.2",
"typescript": "2.4.2",
"mocha": "3.1.2",
"mocha": "3.5.2",
"node-mocks-http": "1.2.3",
"sinon": "1.17.6"
},
Expand Down