Skip to content

Commit

Permalink
renamed test labels for more clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Akamaozu committed Dec 10, 2016
1 parent d731919 commit be30758
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions test/test.js
Expand Up @@ -218,7 +218,7 @@ describe('Supe Test Suite', function(){
supervisor = supe({ retries: 0 });
});

it('sends a citizen-specific notice when it shuts down', function( done ){
it('sends notice "(name)-shutdown" when a citizen shuts down', function( done ){

this.timeout( 15000 );

Expand All @@ -235,7 +235,7 @@ describe('Supe Test Suite', function(){
supervisor.start( 'one-time-logger', './test/citizen/one-time-logger' );
});

it('sends a general notice when any citizen shuts down', function( done ){
it('sends notice "citizen-shutdown" when any citizen shuts down', function( done ){

this.timeout( 15000 );

Expand Down Expand Up @@ -264,7 +264,7 @@ describe('Supe Test Suite', function(){
}, 2000 );
});

it('sends a citizen-specific notice on crash', function( done ){
it('sends notice "(name)-crashed" on crash', function( done ){

this.timeout( 10000 );

Expand All @@ -280,7 +280,7 @@ describe('Supe Test Suite', function(){
supervisor.start( 'one-time-crasher', './test/citizen/one-time-crasher', { retries: 0 } );
});

it('sends a general notice when any citizen crashes', function( done ){
it('sends notice "citizen-crashed" when any citizen crashes', function( done ){

this.timeout( 15000 );

Expand Down Expand Up @@ -309,7 +309,7 @@ describe('Supe Test Suite', function(){
}, 2000 );
});

it('sends a citizen-specific notice when crashed ctitzen is restarted', function( done ){
it('sends notice "(name)-auto-restarted" when crashed citizen is restarted', function( done ){

this.timeout( 10000 );

Expand All @@ -326,7 +326,7 @@ describe('Supe Test Suite', function(){
supervisor.start( name, './test/citizen/one-time-crasher', { retries: 1 } );
});

it('sends a general notice when any crashed citizen is restarted', function( done ){
it('sends notice "citizen-auto-restarted" when any crashed citizen is restarted', function( done ){

this.timeout( 15000 );

Expand Down Expand Up @@ -354,27 +354,6 @@ describe('Supe Test Suite', function(){
supervisor.start( second_citizen_name, './test/citizen/one-time-crasher', { retries: 1 });
}, 1000 );
});

it('sends a notice when it receives mail from a citizen', function( done ){

this.timeout( 10000 );

var received_mail = false;

supervisor.noticeboard.watch( 'supervisor-message', 'do-assertions', function( msg ){

if( msg.notice.type !== 'mail' ) return;

received_mail = true;

assert.equal( received_mail === true, true, 'did not detect specific citizen crash' );
done();
});

var mailer = supervisor.start( 'one-time-mailer', './test/citizen/one-time-mailer' );

mailer.mail.send( 'ohayo gozaimasu' );
});
});

describe('Supervisor Behavior', function(){
Expand Down Expand Up @@ -405,6 +384,34 @@ describe('Supe Test Suite', function(){
supervisor.start( citizen_name, './test/citizen/one-time-crasher', { retries: 1 });
});

it('will not automatically restart citizen that crashed excessively', function( done ){

this.timeout( 0 );

var citizen_name = 'crasher',
max_restarts = 3,
restarts = 0;

supervisor.noticeboard.watch( citizen_name + '-auto-restarted', 'count-auto-restarts', function(){

restarts += 1;

if( restarts > max_restarts ) done( new Error( 'restarted citizen more than permitted amount of times' ) );
});

supervisor.noticeboard.watch( citizen_name + '-excessive-crash', 'do-assertions', function(){

// wait two seconds before doing assertions, just in case
setTimeout( function(){

assert.equal( restarts === max_restarts, true, 'current restarts does not match max allowed restarts' );
done();
}, 2000 );
});

supervisor.start( citizen_name, './test/citizen/one-time-crasher', { retries: max_restarts });
});

it('will route mail to addressed citizen', function( done ){

this.timeout( 10000 );
Expand All @@ -413,8 +420,6 @@ describe('Supe Test Suite', function(){

var envelope = msg.notice;

console.log( 'just received msg', envelope );

if( envelope.type !== 'mail' ) return;
if( envelope.from !== 'routed-mail-receiver' ) return;
if( envelope.msg.received_mail_from !== 'routed-mail-sender' ) return;
Expand Down

0 comments on commit be30758

Please sign in to comment.