Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing a few tests and trying a new route to test events. Changed som…

…e options for runTests.js.

    -d use the dot matrix output
    -s supress stdout during test running (not perfect yet)

There are still intermittent failures on my system, but they seem tied to my setup specifically.
  • Loading branch information...
commit 05c2b35520a4ff7cf8eec760026ed6c7779f59f5 1 parent f438d78
@temas temas authored
View
2  Common/node/synclet/dataaccess.js
@@ -62,4 +62,4 @@ module.exports = function(app) {
}
});
});
-}
+}
View
9 Common/node/synclet/datastore.js
@@ -106,8 +106,13 @@ exports.getAllCurrent = function(type, callback, options) {
options = options || {};
var m = mongo.collections[type];
if(!m) {
- mongo.addCollection(type);
- m = mongo.collections[type];
+ try {
+ mongo.addCollection(type);
+ } catch (E) {
+ callback(E, []);
+ return;
+ }
+ m = mongo.collections[type];
}
m.find({}, options).toArray(callback);
}
View
2  package.json
@@ -29,7 +29,7 @@
"api-easy": "=0.2.3",
"http-proxy": "=0.5.10",
"xml2js": "=0.1.6",
- "vows": "=0.5.8",
+ "vows": ">=0.5.8",
"wrench": "=1.1.0",
"eyes": "=0.1.6",
"knox": "=0.0.8",
View
2  tests/Data.tests/testSynclet/me.json
@@ -4,7 +4,7 @@
"desc":"testSynclet",
"frequency":120,
"status":"stable",
- "srcdir":"Connectors/testSynclet",
+ "srcdir":"Tests/testSynclet",
"id":"testSynclet",
"handle":"testSynclet",
"mongoId":"notId",
View
22 tests/Tests/disabletest/disabletest.js
@@ -18,16 +18,20 @@ app.get('/', function(req, res) {
res.end();
});
+var fullData = "";
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
- var processInfo = JSON.parse(chunk);
- locker.initClient(processInfo);
- process.chdir(processInfo.workingDirectory);
- locker.connectToMongo(function(mongo) {
- collections = mongo.collections;
- app.listen(0, function() {
- process.stdout.write(JSON.stringify({port: app.address().port}));
+ fullData += chunk;
+ if (fullData.indexOf("\n") > 0) {
+ var processInfo = JSON.parse(chunk);
+ locker.initClient(processInfo);
+ process.chdir(processInfo.workingDirectory);
+ locker.connectToMongo(function(mongo) {
+ collections = mongo.collections;
+ app.listen(0, function() {
+ process.stdout.write(JSON.stringify({port: app.address().port}));
+ });
});
- });
+ }
});
-process.stdin.resume();
+process.stdin.resume();
View
0  Connectors/testSynclet/testSynclet.js → tests/Tests/testSynclet/testSynclet.js
File renamed without changes
View
0  Connectors/testSynclet/testSynclet.synclet → tests/Tests/testSynclet/testSynclet.synclet
File renamed without changes
View
75 tests/lsyncmanager-test-local.js
@@ -17,13 +17,21 @@ var vows = require("vows")
, lconfig = require("lconfig")
, fs = require('fs')
, mongo
- , eventCount = 0
- , events = []
- , nsEventCount = 0
- , nsEvents = []
+ , allEvents = {}
, request = require('request')
+ , primaryType = "testSync/testSynclet"
+ , otherType = "eventType/testSynclet"
;
lconfig.load("config.json");
+var levents = require("levents");
+var realFireEvent = levents.fireEvent;
+levents.fireEvent = function(type, id, action, obj) {
+ if (type == primaryType || type == otherType) {
+ if (!allEvents.hasOwnProperty(type)) allEvents[type] = [];
+ allEvents[type].push(obj);
+ }
+}
+
var syncManager = require("lsyncmanager.js");
var lmongoclient = require('../Common/node/lmongoclient.js')(lconfig.mongo.host, lconfig.mongo.port, 'synclets', ['testSynclet_testSync', 'testSynclet_dataStore']);
@@ -119,6 +127,7 @@ vows.describe("Synclet Manager").addBatch({
},
"Installed services can be executed immediately rather than waiting for next run" : {
topic:function() {
+ allEvents = {};
syncManager.syncNow("testSynclet", this.callback);
},
"successfully" : function(err, status) {
@@ -133,7 +142,7 @@ vows.describe("Synclet Manager").addBatch({
});
},
"successfully" : function(err, count) {
- assert.equal(count, 1);
+ assert.equal(allEvents[primaryType].length, 3);
}
}
}
@@ -161,30 +170,33 @@ vows.describe("Synclet Manager").addBatch({
"files": function(err, data) {
assert.equal(data.toString(), '{"timeStamp":1312325283583,"data":{"id":5,"notId":5,"random":"data"}}\n');
}
- }/*,
+ },
"and after generating " : {
- topic: eventCount,
+ topic: allEvents,
"correct number of events" : function(topic) {
- assert.equal(eventCount, 3);
+ assert.equal(allEvents[primaryType].length, 3);
},
"with correct data" : function(topic) {
+ /*
assert.equal(events[0].fromService, 'synclet/testSynclet');
assert.equal(events[1].fromService, 'synclet/testSynclet');
assert.equal(events[2].fromService, 'synclet/testSynclet');
- assert.equal(events[0].obj.type, 'delete');
- assert.equal(events[2].obj.type, 'new');
- assert.equal(events[0].obj.data.notId, 1);
- assert.equal(events[1].obj.data.notId, 500);
+ */
+ var events = allEvents[primaryType];
+ assert.equal(events[0].type, 'delete');
+ assert.equal(events[2].type, 'new');
+ assert.equal(events[0].data.notId, 1);
+ assert.equal(events[1].data.notId, 500);
events = [];
- eventCount = 0;
},
"correct types of events": function(topic) {
- assert.equal(nsEventCount, 1);
- assert.equal(nsEvents[0].obj.type, 'new');
- assert.equal(nsEvents[0].obj.data.random, 'data');
+ var nsEvents = allEvents[otherType];
+ assert.equal(nsEvents.length, 1);
+ assert.equal(nsEvents[0].type, 'new');
+ assert.equal(nsEvents[0].data.random, 'data');
+ nsEvents = [];
}
}
- */
}).addBatch({
"Querying the data API returns the data" : {
topic: function() {
@@ -199,39 +211,43 @@ vows.describe("Synclet Manager").addBatch({
}).addBatch({
"Running testSynclet again" : {
topic: function() {
+ allEvents[primaryType] = [];
syncManager.syncNow("testSynclet", this.callback);
},
"with no data will leave everything intact" : function(topic) {
- assert.equal(eventCount, 0);
+ var events = allEvents[primaryType];
+ assert.equal(events.length, 0);
assert.equal(events[0], undefined);
- events = [];
- eventCount = 0;
}
}
}).addBatch({
"Removing IDs from the config will" : {
topic: function() {
+ allEvents[primaryType] = [];
var self = this;
- syncManager.syncNow("testSynclet", function() {
- mongo.collections.testSynclet_testSync.count(self.callback);
+ mongo.collections.testSynclet_testSync.drop(function() {
+ syncManager.syncNow("testSynclet", function() {
+ mongo.collections.testSynclet_testSync.count(self.callback);
+ });
});
},
"will generate a delete event and remove the row from mongo" : function(err, count) {
+ var events = allEvents[primaryType];
assert.equal(count, 0);
- assert.equal(eventCount, 1);
- assert.equal(events[0].obj.type, 'delete');
- assert.equal(events[0].obj.data.notId, 500);
+ assert.equal(events.length, 1);
+ assert.equal(events[0].type, 'delete');
+ assert.equal(events[0].data.notId, 500);
}
}
}).addBatch({
"Available services" : {
"gathered from the filesystem" : {
- topic:syncManager.scanDirectory("Connectors"),
+ topic:syncManager.scanDirectory("Tests"),
"found a service": function() {
assert.ok(syncManager.synclets().available.length > 0);
},
"and can be installed" : {
- topic:syncManager.install({srcdir:"Connectors/testSynclet","auth" : {"consumerKey":"daKey","consumerSecret":"daPassword"}}),
+ topic:syncManager.install({srcdir:"Tests/testSynclet","auth" : {"consumerKey":"daKey","consumerSecret":"daPassword"}}),
"by giving a valid install instance" : function(svcMetaInfo) {
assert.include(svcMetaInfo, "synclets");
},
@@ -249,7 +265,7 @@ vows.describe("Synclet Manager").addBatch({
}
},
"and can be installed a second time" : {
- topic:syncManager.install({srcdir:"Connectors/testSynclet"}),
+ topic:syncManager.install({srcdir:"Tests/testSynclet"}),
"by giving a valid install instance" : function(svcMetaInfo) {
assert.include(svcMetaInfo, "id");
},
@@ -264,6 +280,9 @@ vows.describe("Synclet Manager").addBatch({
}
}
}
+ },
+ teardown : function() {
+ levents.fireEvent = realFireEvent;
}
}).export(module);
View
19 tests/runTests.js
@@ -50,6 +50,8 @@ if (process.argv.length > 2) {
if (process.argv[2] == "-h" || process.argv[2] == "-?") {
process.stdout.write("Usage: runTests [-l <group name>][-f] [files or groups to run]\n");
process.stdout.write(" -h You found me!\n");
+ process.stdout.write(" -s Suppress the output from test running\n");
+ process.stdout.write(" -d Use the dot matrix style reporter\n");
process.stdout.write(" -l List all of the available groups when no group is given or\n");
process.stdout.write(" all of the files ran in a group.\n");
process.stdout.write(" -f The remaining arguments are treated as files to run\n");
@@ -90,7 +92,7 @@ if (process.argv.length > 2) {
} else {
// We'll process the groups later into indivdual files
for (var x = 2; x < process.argv.length; ++x) {
- runGroups.push(process.argv[x]);
+ if (process.argv[x][0] != "-") runGroups.push(process.argv[x]);
}
}
}
@@ -127,12 +129,19 @@ try {
}
setTimeout(function() {
- var vowsArgument = '--dot-matrix';
- if (process.argv[2] == "-x") {
- vowsArgument = '--xunit';
+ var vowsArgument = [];//["--supress-stdout"];
+ if (process.argv.indexOf("-x") > 0) {
+ vowsArgument.push('--xunit');
+ } else if (process.argv.indexOf("-d") > 0) {
+ vowsArgument.push("--dot-matrix");
+ } else {
+ vowsArgument.push("--spec");
+ }
+ if (process.argv.indexOf("-s") > 0) {
+ vowsArgument.push("--supress-stdout");
}
- var vowsProcess = require("child_process").spawn(__dirname + "/../node_modules/vows/bin/vows", [vowsArgument].concat(runFiles));
+ var vowsProcess = require("child_process").spawn(__dirname + "/../node_modules/vows/bin/vows", vowsArgument.concat(runFiles));
vowsProcess.stdout.on("data", function(data) {
process.stdout.write(data);
});
Please sign in to comment.
Something went wrong with that request. Please try again.