From fd0b6fcb96687cfb7854d6418f7949c67c996b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 29 Jul 2016 16:49:29 +0200 Subject: [PATCH] test: fix change-tracking setup The remote-connector test has misconfigured the client (remote) model, where the client model was trying to keep track of changes. That's redundant because it's up to the server model (attached directly to the database) to track changes. This commit fixes that configuration and also cleans up the test code a little bit to make it easier to distinguish between the remote (client) model and the server model. --- test/remote-connector.test.js | 19 +++++++++++++++---- test/util/model-tests.js | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/test/remote-connector.test.js b/test/remote-connector.test.js index 720701ff..5118de64 100644 --- a/test/remote-connector.test.js +++ b/test/remote-connector.test.js @@ -25,13 +25,24 @@ describe('RemoteConnector', function() { done(); }); }, + + // We are defining the model attached to the remote connector datasource, + // therefore change tracking must be disabled, only the remote API for + // replication should be present + trackChanges: false, + enableRemoteReplication: true, + onDefine: function(Model) { - var RemoteModel = Model.extend('Remote' + Model.modelName, {}, - { plural: Model.pluralModelName }); - RemoteModel.attachTo(loopback.createDataSource({ + var ServerModel = Model.extend('Server' + Model.modelName, {}, { + plural: Model.pluralModelName, + // This is the model running on the server & attached to a real + // datasource, that's the place where to keep track of changes + trackChanges: true, + }); + ServerModel.attachTo(loopback.createDataSource({ connector: loopback.Memory, })); - remoteApp.model(RemoteModel); + remoteApp.model(ServerModel); }, }); diff --git a/test/util/model-tests.js b/test/util/model-tests.js index 814108e3..b6fea310 100644 --- a/test/util/model-tests.js +++ b/test/util/model-tests.js @@ -48,7 +48,8 @@ module.exports = function defineModelTestsWithDataSource(options) { 'domain': String, 'email': String, }, { - trackChanges: true, + trackChanges: options.trackChanges !== false, + enableRemoteReplication: options.enableRemoteReplication, }); User.attachTo(dataSource);