Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix failing unit test #11

Merged
merged 3 commits into from

2 participants

@SLaks

test form file upload was calling StreamUtil.equal synchronously and failing

@SLaks

I'm not sure why the tests are failing; it works on my machine.

It looks like an intermittent timeout

@SLaks

This commit fixes #10

@sp
Owner

This was a synchronous call because testpilot can handle asserts on promises - are you running the tests with testpilot?

@SLaks

Yes, I am.
Are you sure?

The CI server was failing (on the current master branch) because of this. (https://travis-ci.org/capsela/capsela/jobs/2892751/#L422)

@sp
Owner
sp commented

Sorry, synchronous is the wrong term - the call is still sync, it's just the promise is resolved before the assert now, and most importantly, the assertion is made on the promise resolution value before the stage return promise (d) is resolved. This looks good, thanks for the work.

@sp sp merged commit ae07275 into capsela:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  lib/Server.js
@@ -243,7 +243,7 @@ var Server = Service.extend(
t.log(Log.INFO, logFields.join(' '));
}
- ).end();
+ ).done();
},
///////////////////////////////////////////////////////////////////////////////
View
4 testing/tests/AppTest.js
@@ -140,7 +140,7 @@ exports.basics = {
test.ok(stopped);
test.done();
}
- ).end();
+ ).done();
},
"test addService/start/stop": function(test) {
@@ -191,7 +191,7 @@ exports.basics = {
test.ok(stopped);
test.done();
}
- ).end();
+ ).done();
},
"test start w/error": function(test) {
View
2  testing/tests/BrowserTest.js
@@ -62,7 +62,7 @@ module.exports["basics"] = {
function(response) {
test.done();
}
- ).end();
+ ).done();
request.bodyStream.end();
}
View
6 testing/tests/FileResponseTest.js
@@ -63,7 +63,7 @@ module.exports["basics"] = {
test.equal(err.message, "file not found or something, man");
test.done();
- }).end();
+ }).done();
},
"test create success": function(test) {
@@ -89,7 +89,7 @@ module.exports["basics"] = {
test.equal(response.getLastModified().getTime(), 72000);
test.done();
- }).end();
+ }).done();
},
"test write body": function(test) {
@@ -133,6 +133,6 @@ module.exports["basics"] = {
test.equal(data.toString(), 'oh my goodness!');
test.done();
- }).end();
+ }).done();
}
};
View
2  testing/tests/FormTest.js
@@ -208,7 +208,7 @@ module.exports["basics"] = {
function(data) {
test.done();
}
- ).end();
+ ).done();
req.sendBody();
},
View
4 testing/tests/RequestTest.js
@@ -299,7 +299,7 @@ module.exports["basics"] = {
function(obj) {
test.deepEqual(obj, bodyObj);
test.done();
- }).end();
+ }).done();
// stream the request body
request.getBodyStream().end(JSON.stringify(bodyObj), 'utf8');
@@ -313,7 +313,7 @@ module.exports["basics"] = {
function(err) {
test.equal(err.message, 'request body is not valid JSON');
test.done();
- }).end();
+ }).done();
// stream the request body
request.getBodyStream().end('yo, what gives?', 'utf8');
View
18 testing/tests/ServerTest.js
@@ -268,7 +268,7 @@ module.exports["construct/start"] = {
server.isReady().then(function() {
ready = true;
test.done();
- }).end();
+ }).done();
setTimeout(function() {
d[0].resolve();
@@ -316,7 +316,7 @@ module.exports["construct/start"] = {
server.start().then(function() {
test.ok(server.isRunning());
test.done();
- }).end();
+ }).done();
},
"test construct/start secure": function(test) {
@@ -359,7 +359,7 @@ module.exports["construct/start"] = {
server.start().then(function() {
fakeServer.onRequest(req, res);
- }).end();
+ }).done();
},
"test construct/start secure with TLS-PSK connection": function(test) {
@@ -420,7 +420,7 @@ module.exports["construct/start"] = {
server.start().then(function() {
fakeServer.onRequest(req, res);
- }).end();
+ }).done();
},
"test construct/start insecure": function(test) {
@@ -463,7 +463,7 @@ module.exports["construct/start"] = {
server.start().then(function() {
fakeServer.onRequest(req, res);
- }).end();
+ }).done();
},
"test stop": function(test) {
@@ -508,7 +508,7 @@ module.exports["construct/start"] = {
function() {
test.equal(server.isRunning(), false);
test.done();
- }).end();
+ }).done();
}
};
@@ -606,8 +606,10 @@ module.exports["form processing"] = {
// compare to file that was sent
var expected = fs.readFileSync(testbench.fixturesDir + '/form-data/chupacabra.jpg');
- test.ok(StreamUtil.equal(expected, fileContent), "received file doesn't match expected");
- d.resolve();
+ StreamUtil.equal(expected, fileContent).then(function (equal) {
+ test.ok(equal, "received file doesn't match expected");
+ d.resolve();
+ });
});
});
View
2  testing/tests/ServiceTest.js
@@ -71,7 +71,7 @@ exports.basics = {
test.done();
}
- ).end();
+ ).done();
},
"test start/stop w/out functions": function(test) {
View
2  testing/tests/ViewRegistryTest.js
@@ -88,7 +88,7 @@ module.exports["basics"] = {
test.ok(vr.getView('user') instanceof JsonTemplate);
test.done();
}
- ).end();
+ ).done();
}
};
View
26 testing/tests/stages/DispatcherTest.js
@@ -65,7 +65,7 @@ module.exports["basics"] = {
function() {
test.deepEqual(loaded, {"test1": 1, "default": 1});
test.done();
- }).end();
+ }).done();
},
"test isReady": function(test) {
@@ -121,7 +121,7 @@ module.exports["basics"] = {
test.deepEqual(loaded, {"test1": 1, "default": 1});
test.done();
}
- ).end();
+ ).done();
},
"test setUp with load controller error": function(test) {
@@ -199,7 +199,7 @@ module.exports["resolving"] = {
test.done();
}
- ).end();
+ ).done();
}
};
@@ -220,7 +220,7 @@ module.exports["dispatching"] = {
test.equal(result, 'fell through');
test.done();
}
- ).end();
+ ).done();
},
"test no action match": function(test) {
@@ -241,7 +241,7 @@ module.exports["dispatching"] = {
test.equal(result, 'fell through');
test.done();
}
- ).end();
+ ).done();
},
"test default action match": function(test) {
@@ -258,7 +258,7 @@ module.exports["dispatching"] = {
test.equal(result, 'test1 default action called');
test.done();
}
- ).end();
+ ).done();
},
"test dispatch null route": function(test) {
@@ -275,7 +275,7 @@ module.exports["dispatching"] = {
test.equal(result, 'default default action called');
test.done();
}
- ).end();
+ ).done();
},
"test dispatch default controller": function(test) {
@@ -292,7 +292,7 @@ module.exports["dispatching"] = {
test.equal(result, 'default hitMe action called');
test.done();
}
- ).end();
+ ).done();
},
"test dispatch with querystring": function(test) {
@@ -313,7 +313,7 @@ module.exports["dispatching"] = {
function(response) {
test.equal(response, 'ok');
test.done();
- }).end();
+ }).done();
},
"test dispatch success": function(test) {
@@ -330,7 +330,7 @@ module.exports["dispatching"] = {
test.equal(result, 'called edit!');
test.done();
}
- ).end();
+ ).done();
},
"test infer default": function(test) {
@@ -354,7 +354,7 @@ module.exports["dispatching"] = {
test.equal(result, 'here i am!');
test.done();
}
- ).end();
+ ).done();
},
"test dispatch with trailing slash": function(test) {
@@ -378,7 +378,7 @@ module.exports["dispatching"] = {
test.equal(result, 'here i am!');
test.done();
}
- ).end();
+ ).done();
},
"test no result falls through": function(test) {
@@ -407,6 +407,6 @@ module.exports["dispatching"] = {
test.equal(result, 'fell through');
test.done();
}
- ).end();
+ ).done();
}
};
View
6 testing/tests/stages/ErrorHandlerTest.js
@@ -68,7 +68,7 @@ module.exports = {
test.equal(response.statusCode, 404);
test.equal(response.view, 'error');
test.done();
- }).end();
+ }).done();
},
"test catch empty promise": function(test) {
@@ -87,7 +87,7 @@ module.exports = {
test.equal(response.statusCode, 404);
test.equal(response.view, 'error');
test.done();
- }).end();
+ }).done();
},
"test catch thrown error": function(test) {
@@ -111,6 +111,6 @@ module.exports = {
});
test.equal(response.statusCode, 404);
test.done();
- }).end();
+ }).done();
}
};
View
26 testing/tests/stages/FileServerTest.js
@@ -143,7 +143,7 @@ exports["basics"] = {
test.equal(data.length, contentLength);
test.done();
}
- ).end();
+ ).done();
},
"test missing file falls through": function(test) {
@@ -228,7 +228,7 @@ exports["default file"] = {
test.equal(response, 'ok');
test.done();
}
- ).end();
+ ).done();
},
"test default file option without trailing slash": function(test) {
@@ -253,7 +253,7 @@ exports["default file"] = {
test.ok(data.toString().indexOf('<p>chickens</p>') > 0);
test.done();
}
- ).end();
+ ).done();
},
"test default file option with trailing slash": function(test) {
@@ -278,7 +278,7 @@ exports["default file"] = {
test.ok(data.toString().indexOf('<p>chickens</p>') > 0);
test.done();
}
- ).end();
+ ).done();
},
"test default file in subdirectory": function(test) {
@@ -303,7 +303,7 @@ exports["default file"] = {
test.ok(data.toString().indexOf('font-family:') > 0);
test.done();
}
- ).end();
+ ).done();
}
}
@@ -347,7 +347,7 @@ exports["file types"] = {
test.equal(data.toString().indexOf('snow monkeys!'), 0);
test.done();
}
- ).end();
+ ).done();
});
},
@@ -373,7 +373,7 @@ exports["file types"] = {
test.ok(data.toString().indexOf('<p>chickens</p>') > 0);
test.done();
}
- ).end();
+ ).done();
});
},
@@ -399,7 +399,7 @@ exports["file types"] = {
test.ok(data.toString().indexOf('font-family:') > 0);
test.done();
}
- ).end();
+ ).done();
});
},
@@ -425,7 +425,7 @@ exports["file types"] = {
test.ok(data.toString().indexOf('function() {') > 0);
test.done();
}
- ).end();
+ ).done();
});
},
@@ -451,7 +451,7 @@ exports["file types"] = {
test.ok(data.toString().indexOf('function() {') > 0);
test.done();
}
- ).end();
+ ).done();
});
},
@@ -471,7 +471,7 @@ exports["file types"] = {
test.equal(response.getHeader('Last-Modified'), stat.mtime.toUTCString());
test.done();
}
- ).end();
+ ).done();
});
},
@@ -505,7 +505,7 @@ exports["file types"] = {
test.equal(response.getHeader('Expires'), new Date(now + 365 * 86400 * 1000).toUTCString());
test.equal(response.getHeader('Last-Modified'), stat.mtime.toUTCString());
test.done();
- }).end();
+ }).done();
});
},
@@ -552,6 +552,6 @@ exports["file types"] = {
function(response) {
test.equal(response.statusCode, 200);
test.done();
- }).end();
+ }).done();
}
};
View
4 testing/tests/stages/ViewRendererTest.js
@@ -115,7 +115,7 @@ module.exports["basics"] = {
test.ok(response instanceof ViewResponse);
test.equal(response.view, view);
test.done();
- }).end();
+ }).done();
},
"test intercept viewResponse w/o view": function(test) {
@@ -138,7 +138,7 @@ module.exports["basics"] = {
test.equal(response, res);
test.equal(response.renderer, r);
test.done();
- }).end();
+ }).done();
}
};
Something went wrong with that request. Please try again.