From ddb5327e644fd6a624224668372f8e81033bc851 Mon Sep 17 00:00:00 2001 From: David Cheung Date: Tue, 24 May 2016 16:46:32 -0400 Subject: [PATCH] Update tests for strong-error-handler Fix rest-adapter related test case switching to strong-error-handler Only affect the test-cases calling rest methods --- test/access-token.test.js | 1 + test/acl.test.js | 1 + test/app.test.js | 1 + test/fixtures/access-control/server/config.json | 8 +++++++- .../shared-methods/both-configs-set/server/config.json | 3 ++- .../config-default-false/server/config.json | 3 ++- .../shared-methods/config-default-true/server/config.json | 3 ++- .../config-defined-false/server/config.json | 3 ++- .../shared-methods/config-defined-true/server/config.json | 3 ++- .../model-config-default-false/server/config.json | 3 ++- .../model-config-default-true/server/config.json | 3 ++- .../model-config-defined-false/server/config.json | 3 ++- .../model-config-defined-true/server/config.json | 3 ++- test/fixtures/simple-app/server/config.json | 8 +++++++- test/fixtures/simple-integration-app/server/config.json | 4 ++++ test/fixtures/user-integration-app/server/config.json | 4 ++++ test/helpers/loopback-testing-helper.js | 2 ++ test/model.test.js | 1 + test/relations.integration.js | 4 ++-- test/remote-connector.test.js | 1 + test/remoting.integration.js | 3 ++- test/replication.rest.test.js | 1 + test/rest.middleware.test.js | 1 + test/user.test.js | 1 + 24 files changed, 54 insertions(+), 14 deletions(-) diff --git a/test/access-token.test.js b/test/access-token.test.js index eeb5b794d..ab3912557 100644 --- a/test/access-token.test.js +++ b/test/access-token.test.js @@ -503,6 +503,7 @@ function createTestApp(testToken, settings, done) { app.use(cookieParser('secret')); app.use(loopback.token(tokenSettings)); + app.set('remoting', { errorHandler: { debug: true, log: false }}); app.get('/token', function(req, res) { res.cookie('authorization', testToken.id, { signed: true }); res.cookie('access_token', testToken.id, { signed: true }); diff --git a/test/acl.test.js b/test/acl.test.js index e774e3e4d..dd2ff474f 100644 --- a/test/acl.test.js +++ b/test/acl.test.js @@ -396,6 +396,7 @@ describe('access check', function() { var app; before(function() { app = loopback(); + app.set('remoting', { errorHandler: { debug: true, log: false }}); app.use(loopback.rest()); app.enableAuth(); app.dataSource('test', { connector: 'memory' }); diff --git a/test/app.test.js b/test/app.test.js index d76287cf5..0cf517c47 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -613,6 +613,7 @@ describe('app', function() { var app, db; beforeEach(function() { app = loopback(); + app.set('remoting', { errorHandler: { debug: true, log: false }}); db = loopback.createDataSource({ connector: loopback.Memory }); }); diff --git a/test/fixtures/access-control/server/config.json b/test/fixtures/access-control/server/config.json index 67364ab47..bfc186716 100644 --- a/test/fixtures/access-control/server/config.json +++ b/test/fixtures/access-control/server/config.json @@ -1,5 +1,11 @@ { "port": 3000, "host": "0.0.0.0", - "legacyExplorer": false + "legacyExplorer": false, + "remoting": { + "errorHandler": { + "debug": true, + "log": false + } + } } \ No newline at end of file diff --git a/test/fixtures/shared-methods/both-configs-set/server/config.json b/test/fixtures/shared-methods/both-configs-set/server/config.json index 13db709e9..faa4bb021 100644 --- a/test/fixtures/shared-methods/both-configs-set/server/config.json +++ b/test/fixtures/shared-methods/both-configs-set/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false }, "sharedMethods": { "*": false, diff --git a/test/fixtures/shared-methods/config-default-false/server/config.json b/test/fixtures/shared-methods/config-default-false/server/config.json index 4a919642f..560c8e68e 100644 --- a/test/fixtures/shared-methods/config-default-false/server/config.json +++ b/test/fixtures/shared-methods/config-default-false/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false }, "sharedMethods": { "*": false diff --git a/test/fixtures/shared-methods/config-default-true/server/config.json b/test/fixtures/shared-methods/config-default-true/server/config.json index 15c6c80f5..b4fbaeff1 100644 --- a/test/fixtures/shared-methods/config-default-true/server/config.json +++ b/test/fixtures/shared-methods/config-default-true/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false }, "sharedMethods": { "*": true diff --git a/test/fixtures/shared-methods/config-defined-false/server/config.json b/test/fixtures/shared-methods/config-defined-false/server/config.json index 21ff03a33..a234dee55 100644 --- a/test/fixtures/shared-methods/config-defined-false/server/config.json +++ b/test/fixtures/shared-methods/config-defined-false/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false }, "sharedMethods": { "find": false diff --git a/test/fixtures/shared-methods/config-defined-true/server/config.json b/test/fixtures/shared-methods/config-defined-true/server/config.json index e59e3e582..43cbd95a3 100644 --- a/test/fixtures/shared-methods/config-defined-true/server/config.json +++ b/test/fixtures/shared-methods/config-defined-true/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false }, "sharedMethods": { "find": true diff --git a/test/fixtures/shared-methods/model-config-default-false/server/config.json b/test/fixtures/shared-methods/model-config-default-false/server/config.json index 61ed16d6c..d490e0755 100644 --- a/test/fixtures/shared-methods/model-config-default-false/server/config.json +++ b/test/fixtures/shared-methods/model-config-default-false/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false } }, "legacyExplorer": false diff --git a/test/fixtures/shared-methods/model-config-default-true/server/config.json b/test/fixtures/shared-methods/model-config-default-true/server/config.json index 61ed16d6c..d490e0755 100644 --- a/test/fixtures/shared-methods/model-config-default-true/server/config.json +++ b/test/fixtures/shared-methods/model-config-default-true/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false } }, "legacyExplorer": false diff --git a/test/fixtures/shared-methods/model-config-defined-false/server/config.json b/test/fixtures/shared-methods/model-config-defined-false/server/config.json index 61ed16d6c..d490e0755 100644 --- a/test/fixtures/shared-methods/model-config-defined-false/server/config.json +++ b/test/fixtures/shared-methods/model-config-defined-false/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false } }, "legacyExplorer": false diff --git a/test/fixtures/shared-methods/model-config-defined-true/server/config.json b/test/fixtures/shared-methods/model-config-defined-true/server/config.json index 61ed16d6c..d490e0755 100644 --- a/test/fixtures/shared-methods/model-config-defined-true/server/config.json +++ b/test/fixtures/shared-methods/model-config-defined-true/server/config.json @@ -20,7 +20,8 @@ }, "cors": false, "errorHandler": { - "disableStackTrace": false + "debug": true, + "log": false } }, "legacyExplorer": false diff --git a/test/fixtures/simple-app/server/config.json b/test/fixtures/simple-app/server/config.json index b8d6d71eb..e40d7aeb2 100644 --- a/test/fixtures/simple-app/server/config.json +++ b/test/fixtures/simple-app/server/config.json @@ -1,5 +1,11 @@ { "port": 3000, "host": "127.0.0.1", - "legacyExplorer": false + "legacyExplorer": false, + "remoting": { + "errorHandler": { + "debug": true, + "log": false + } + } } diff --git a/test/fixtures/simple-integration-app/server/config.json b/test/fixtures/simple-integration-app/server/config.json index c7cce73ed..64caa4df4 100644 --- a/test/fixtures/simple-integration-app/server/config.json +++ b/test/fixtures/simple-integration-app/server/config.json @@ -9,6 +9,10 @@ }, "urlencoded": { "limit": "8kb" + }, + "errorHandler": { + "debug": true, + "log": false } }, "legacyExplorer": false diff --git a/test/fixtures/user-integration-app/server/config.json b/test/fixtures/user-integration-app/server/config.json index c7cce73ed..64caa4df4 100644 --- a/test/fixtures/user-integration-app/server/config.json +++ b/test/fixtures/user-integration-app/server/config.json @@ -9,6 +9,10 @@ }, "urlencoded": { "limit": "8kb" + }, + "errorHandler": { + "debug": true, + "log": false } }, "legacyExplorer": false diff --git a/test/helpers/loopback-testing-helper.js b/test/helpers/loopback-testing-helper.js index e27abf4fa..5e5085118 100644 --- a/test/helpers/loopback-testing-helper.js +++ b/test/helpers/loopback-testing-helper.js @@ -67,6 +67,8 @@ _beforeEach.givenModel = function(modelName, attrs, optionalHandler) { var test = this; var app = this.app; var model = app.models[modelName]; + + app.set('remoting', { errorHandler: { debug: true, log: false }}); assert(model, 'cannot get model of name ' + modelName + ' from app.models'); assert(model.dataSource, 'cannot test model ' + modelName + ' without attached dataSource'); diff --git a/test/model.test.js b/test/model.test.js index 4399a7fb0..09829581b 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -125,6 +125,7 @@ describe.onServer('Remote Methods', function() { ); app = loopback(); + app.set('remoting', { errorHandler: { debug: true, log: false }}); app.use(loopback.rest()); app.model(User); }); diff --git a/test/relations.integration.js b/test/relations.integration.js index 33e70000f..dd29ad98e 100644 --- a/test/relations.integration.js +++ b/test/relations.integration.js @@ -263,7 +263,7 @@ describe('relations - integration', function() { lt.describe.whenCalledRemotely('GET', '/stores/:id/widgets/:fk', function() { it('should fail with statusCode 404', function() { assert.equal(this.res.statusCode, 404); - assert.equal(this.res.body.error.status, 404); + assert.equal(this.res.body.error.statusCode, 404); }); }); }); @@ -1652,7 +1652,7 @@ describe('relations - integration', function() { expect(res.body).to.be.an('object'); expect(res.body.error).to.be.an('object'); expect(res.body.error.name).to.equal('Error'); - expect(res.body.error.status).to.equal(500); + expect(res.body.error.statusCode).to.equal(500); expect(res.body.error.message).to.equal('This should not crash the app'); done(); diff --git a/test/remote-connector.test.js b/test/remote-connector.test.js index 934961db9..720701ffd 100644 --- a/test/remote-connector.test.js +++ b/test/remote-connector.test.js @@ -13,6 +13,7 @@ describe('RemoteConnector', function() { beforeEach: function(done) { var test = this; remoteApp = loopback(); + remoteApp.set('remoting', { errorHandler: { debug: true, log: false }}); remoteApp.use(loopback.rest()); remoteApp.listen(0, function() { test.dataSource = loopback.createDataSource({ diff --git a/test/remoting.integration.js b/test/remoting.integration.js index be0f928aa..37552dcf0 100644 --- a/test/remoting.integration.js +++ b/test/remoting.integration.js @@ -22,7 +22,8 @@ describe('remoting - integration', function() { it('should load remoting options', function() { var remotes = app.remotes(); assert.deepEqual(remotes.options, { 'json': { 'limit': '1kb', 'strict': false }, - 'urlencoded': { 'limit': '8kb', 'extended': true }}); + 'urlencoded': { 'limit': '8kb', 'extended': true }, + 'errorHandler': { 'debug': true, log: false }}); }); it('rest handler', function() { diff --git a/test/replication.rest.test.js b/test/replication.rest.test.js index bd98656b7..1ab45b4db 100644 --- a/test/replication.rest.test.js +++ b/test/replication.rest.test.js @@ -462,6 +462,7 @@ describe('Replication over REST', function() { function setupServer(done) { serverApp = loopback(); + serverApp.set('remoting', { errorHandler: { debug: true, log: false }}); serverApp.enableAuth(); serverApp.dataSource('db', { connector: 'memory' }); diff --git a/test/rest.middleware.test.js b/test/rest.middleware.test.js index 39efdfbb5..50ae439f8 100644 --- a/test/rest.middleware.test.js +++ b/test/rest.middleware.test.js @@ -12,6 +12,7 @@ describe('loopback.rest', function() { // override the global app object provided by test/support.js // and create a local one that does not share state with other tests app = loopback({ localRegistry: true, loadBuiltinModels: true }); + app.set('remoting', { errorHandler: { debug: true, log: false }}); var db = app.dataSource('db', { connector: 'memory' }); MyModel = app.registry.createModel('MyModel'); MyModel.attachTo(db); diff --git a/test/user.test.js b/test/user.test.js index b928409c2..c1f9bbe03 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -30,6 +30,7 @@ describe('User', function() { // override the global app object provided by test/support.js // and create a local one that does not share state with other tests app = loopback({ localRegistry: true, loadBuiltinModels: true }); + app.set('remoting', { errorHandler: { debug: true, log: false }}); app.dataSource('db', { connector: 'memory' }); // setup Email model, it's needed by User tests