loopback/test/e2e/replication.e2e.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2014-04-16 14:33:17 +00:00
var path = require('path');
var loopback = require('../../');
var models = require('../fixtures/e2e/models');
var TestModel = models.TestModel;
var LocalTestModel = TestModel.extend('LocalTestModel', {}, {
trackChanges: true,
2014-04-16 14:33:17 +00:00
});
var assert = require('assert');
2014-04-16 14:33:17 +00:00
describe('Replication', function() {
before(function() {
2014-04-16 14:33:17 +00:00
// setup the remote connector
var ds = loopback.createDataSource({
url: 'http://127.0.0.1:3000/api',
connector: loopback.Remote,
2014-04-16 14:33:17 +00:00
});
TestModel.attachTo(ds);
var memory = loopback.memory();
LocalTestModel.attachTo(memory);
});
2014-11-21 02:35:36 +00:00
it('should replicate local data to the remote', function(done) {
var RANDOM = Math.random();
2014-04-16 14:33:17 +00:00
LocalTestModel.create({
n: RANDOM,
}, function(err, created) {
2014-04-16 14:33:17 +00:00
LocalTestModel.replicate(0, TestModel, function() {
2014-11-21 02:35:36 +00:00
if (err) return done(err);
TestModel.findOne({ n: RANDOM }, function(err, found) {
assert.equal(created.id, found.id);
done();
});
2014-04-16 14:33:17 +00:00
});
});
});
});