Skip to content

Commit

Permalink
Spawning kinto test server instances contextually.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Jul 20, 2015
1 parent 0a4b2b9 commit b5d06b9
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 178 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ before_install:
- pip install --user `whoami` virtualenv
- virtualenv .env
- .env/bin/pip install kinto==1.3.1
- .env/bin/pserve test/kinto.ini &
env:
- KINTO_PSERVE_EXECUTABLE=.env/bin/pserve
8 changes: 6 additions & 2 deletions src/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class HTTP extends EventEmitter {
status = res.status;
statusText = res.statusText;
this._checkForDeprecationHeader(headers);
this._checkForBackoffHeader(headers);
this._checkForBackoffHeader(status, headers);
const contentLength = headers.get("Content-Length");
if (!contentLength || contentLength == 0)
return null;
Expand Down Expand Up @@ -91,7 +91,11 @@ export default class HTTP extends EventEmitter {
}
}

_checkForBackoffHeader(headers) {
_checkForBackoffHeader(status, headers) {
// XXX Temporary fix
// see https://github.com/mozilla-services/kinto/issues/148
if (status === 304)
return;
var backoffMs;
const backoffSeconds = parseInt(headers.get("Backoff"), 10);
if (backoffSeconds > 0) {
Expand Down
2 changes: 2 additions & 0 deletions test/api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ describe("Api", () => {

describe("get backoff()", () => {
it("should provide the remaining backoff time in ms if any", () => {
// Make Date#getTime always returning 1000000, for predictability
sandbox.stub(Date.prototype, "getTime").returns(1000 * 1000);
sandbox.stub(root, "fetch").returns(
fakeServerResponse(200, {}, {Backoff: "1000"}));

Expand Down
Loading

0 comments on commit b5d06b9

Please sign in to comment.