Ejemplo n.º 1
0
var events = require('events'),
    http = require("http"),

    assert = require("nodetk/testing/custom_assert"),

    rest_server = require('rest-mongo/http_rest/server'),
    rest_mongo = require('rest-mongo/core'),
    mongo_backend = require('rest-mongo/mongo_backend'),
    schema = require('rest-mongo/tests/schema').schema;



var server;
var client;
var backend = mongo_backend.get_backend({db_name: 'test-rest-mongo'});
var RFactory = rest_mongo.getRFactory(schema, backend);

// Create an emitter which will assert.ok(false) if action not expected
// or call the callback set in emitter_actions (only once).
var emitter = new events.EventEmitter();
var emitter_actions = {};
[ 'CREATE:Person'
, 'REMOVE:Person'
, 'UPDATE:Person'
, 'DELETE:Person'
].forEach(function(action) {
  emitter.on(action, function(){
    var callback = emitter_actions[action];
    if(!callback) assert.ok(false, 'Event '+ action + ' not expexted.');
    delete emitter_actions[action];
    callback.apply(this, arguments);
Ejemplo n.º 2
0
exports.init = function(config) {
  var backend = mongo_backend.get_backend(config.db);
  exports.RFactory = rest_mongo.getRFactory(schema, backend);
};