Skip to content

Commit d5bcac0

Browse files
committed
Improved tests
1 parent f23b402 commit d5bcac0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/internal/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ scServer.on('message', function (m) {
7171
var socket = scClient.connect(options);
7272
socket.once('connect', function () {
7373
if (socket.connected) {
74+
// Subscribe to some events
75+
socket.on('event1', function () {});
76+
socket.on('event2', function () {});
77+
socket.on('event3', function () {});
78+
socket.on('event4', function () {});
79+
7480
console.log('#' + ++socketCount + ' - Socket ' + socket.id + ' connected');
7581

7682
var interval = setInterval(function () {
@@ -162,7 +168,7 @@ scServer.on('message', function (m) {
162168
console.log('Store channels/events after session timeouts:', util.inspect(channels, {depth: 5}));
163169

164170
for (var j in channels) {
165-
var isChannelMapEmpty = JSON.stringify(channels[j]).length < 70;
171+
var isChannelMapEmpty = JSON.stringify(channels[j]).length < 50;
166172
assert(isChannelMapEmpty, 'Channels/events were not cleaned up after sessions timed out');
167173
}
168174
console.log('[Success] Store channels/events were cleaned up after sessions timed out');

test/internal/store.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var fs = require('fs');
22
var http = require('http');
33
var getTestSocketPath = require('./testsocketpath').getTestSocketPath;
4+
var util = require('util');
45

56
module.exports.run = function (store) {
67
console.log(' >> Store PID:', process.pid);
@@ -9,8 +10,13 @@ module.exports.run = function (store) {
910

1011
// Send test data to index.js every second
1112
var testDataInterval = setInterval(function () {
13+
var socketChannelData = store.channelMap.get(['sockets']);
14+
var channels = [];
15+
for (var i in socketChannelData) {
16+
channels = channels.concat(Object.keys(socketChannelData[i]['__iocl']['gle']));
17+
}
1218
var sessionData = Object.keys(store.dataMap.get(['__iocl', 'sed']) || {});
13-
var channels = store.channelMap.getAll();
19+
1420
var req = http.request({
1521
socketPath: resultSocketPath,
1622
method: 'POST'

0 commit comments

Comments
 (0)