Skip to content

Commit

Permalink
tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Jan 26, 2012
1 parent 09df750 commit 1b6afff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions initializers/initSocketServer.js
Expand Up @@ -172,8 +172,8 @@ var initSocketServer = function(api, next){
if(loop == null){loop = true;}
results = {};
results.rooms = {};
for(var i in api.connections){
var thisConnection = api.connections[i];
for(var i in api.socketServer.connections){
var thisConnection = api.socketServer.connections[i];
var thisRoom = thisConnection.room;
if(results.rooms[thisRoom] == null){
results.rooms[thisRoom] = {members: [], membersCount: 0};
Expand Down
10 changes: 3 additions & 7 deletions initializers/initStats.js
Expand Up @@ -7,8 +7,6 @@ var initStats = function(api, next){

api.stats.init = function(api, next){
var stats = {};
stats.numberOfWebRequests = 0;
stats.numberOfSocketRequests = 0;
stats.startTime = new Date().getTime();
stats.pid = process.pid;
api.cache.save(api, "_stats", stats, cacheTime, function(){
Expand All @@ -17,12 +15,10 @@ var initStats = function(api, next){
}

api.stats.load = function(next){
api.stats.calculate(api, function(){
api.stats.calculate(api, function(stats){
api.actionCluster.cache.load(api, "_stats", function(clusterResp){
if(clusterResp == false){
api.cache.load(api, "_stats", function(localResp){
next(localResp);
});
next(stats);
}else{
next(clusterResp);
}
Expand Down Expand Up @@ -51,7 +47,7 @@ var initStats = function(api, next){
};

api.cache.save(api, "_stats", stats, cacheTime, function(){
if(typeof next == "function"){ next(); }
if(typeof next == "function"){ next(stats); }
});
});
}
Expand Down
5 changes: 3 additions & 2 deletions spec/action_status.js
Expand Up @@ -15,11 +15,12 @@ suite.addBatch({
topic: function(){ specHelper.apiTest.get(actionUrl, {} ,this.callback ); },
error: function(res, b){ specHelper.assert.equal(res.body.error, "OK");},
},

"status: stats": {
topic: function(){ specHelper.apiTest.get(actionUrl, {} ,this.callback ); },
stats: function(res, b){
specHelper.assert.isTrue(res.body.stats.numberOfWebRequests > 0);
specHelper.assert.isTrue(res.body.stats.numberOfSocketRequests >= 0);
specHelper.assert.isTrue(res.body.stats.webServer.numberOfWebRequests > 0);
specHelper.assert.isTrue(res.body.stats.socketServer.numberOfSocketRequests >= 0);
specHelper.assert.isTrue(res.body.stats.startTime > 0);
specHelper.assert.isTrue(res.body.stats.uptimeSeconds > 0);
specHelper.assert.isTrue(res.body.stats.pid > 0);
Expand Down
2 changes: 1 addition & 1 deletion spec/api_socket.js
Expand Up @@ -56,7 +56,7 @@ suite.addBatch({
makeSocketRequest(client, this.callback, "status");
}, 'works' : function(resp, d){
specHelper.assert.isObject(d.stats);
specHelper.assert.equal(d.stats.numberOfSocketRequests, 3);
specHelper.assert.equal(d.stats.socketServer.numberOfSocketRequests, 3);
}
}
});
Expand Down

0 comments on commit 1b6afff

Please sign in to comment.