added basic unix socket testing

This commit is contained in:
Brandon Nozaki Miller 2014-09-04 18:50:23 -07:00
parent 3312c6a644
commit 0a58f61224
3 changed files with 104 additions and 1 deletions

View file

@ -38,4 +38,5 @@ ipc.connectTo(
} }
); );
} }
); );

View file

@ -0,0 +1,25 @@
var ipc = require('../../../node-ipc'),
server=__dirname.split('/'),
server=server[server.length-1]
ipc.config.id = server+'-client';
ipc.config.maxRetries=1;
ipc.connectTo(
server,
function(){
ipc.of[server].on(
'connect',
function(){
ipc.of[server].emit(
'test-test',
{
id:ipc.config.id
}
);
process.exit();
}
);
}
);

View file

@ -0,0 +1,77 @@
var ipc = require('../../../node-ipc');
ipc.config.id = __dirname.split('/');
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
ipc.config.maxRetries=1;
ipc.connectTo(
'testHarness',
function(){
ipc.of.testHarness.on(
'connect',
function(){
console.log(ipc.of)
ipc.of.testHarness.emit(
'start.test',
{
id : ipc.config.id,
duration: 2000
}
);
ipc.serve(
function(){
}
);
ipc.server.on(
'connect',
function(){
ipc.of.testHarness.emit(
'pass',
'unix-server-connection'
);
}
)
ipc.server.on(
'socket.disconnected',
function(socket,id){
var test='unix-server-detected-correct-id-disconnection';
if(id==ipc.config.id+'-client'){
ipc.of.testHarness.emit(
'pass',
test
);
}else{
ipc.of.testHarness.emit(
'fail',
test
);
}
ipc.of.testHarness.emit(
'end.test'
);
process.exit(0);
}
)
ipc.server.on(
'test-test',
function(data,socket){
ipc.of.testHarness.emit(
'pass',
'unix-client-message'
);
}
);
ipc.server.define.listen['app.message']='This event type listens for message strings as value of data key.';
ipc.server.start();
}
)
}
);