From 0eb953d0534afc35477736e65567a3c574b7fb63 Mon Sep 17 00:00:00 2001 From: "M. Peter" Date: Wed, 4 Nov 2015 12:02:50 +0100 Subject: [PATCH] added tests for pull#5 --- .travis.yml | 5 ++++- README.md | 1 + _src/test/main.coffee | 46 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5aff22d..0a52d48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,10 @@ language: node_js node_js: - 0.10 - 0.12 + - 4.0 + - 4.1 + - 5.0 - iojs before_script: - "npm install -g mocha grunt-cli" - - "grunt build" \ No newline at end of file + - "grunt build" diff --git a/README.md b/README.md index 7606b51..9597410 100644 --- a/README.md +++ b/README.md @@ -287,6 +287,7 @@ This is an advanced example showing some features in action. ## Release History |Version|Date|Description| |:--:|:--:|:--| +|0.3.8|2015-11-04|Fixed stop behaviour. [Pull#5](https://github.com/mpneuried/rsmq-worker/pull/5). Thanks to [Exinferis](https://github.com/exinferis)| |0.3.7|2015-09-02|Added tests to check the behavior during errors within message processing; Added option `alwaysLogErrors` to prevent console logs if an error event handler was attached. [Issue #3](https://github.com/mpneuried/rsmq-worker/issues/3)| |0.3.6|2015-09-02|Updated dependencies; optimized readme (thanks to [Tobias Lidskog](https://github.com/tobli) for the [pull #4](https://github.com/mpneuried/rsmq-worker/pull/4))| |0.3.5|2015-04-27|again ... fixed argument dispatch for `.send()`| diff --git a/_src/test/main.coffee b/_src/test/main.coffee index 246838d..e2cdd3b 100644 --- a/_src/test/main.coffee +++ b/_src/test/main.coffee @@ -89,7 +89,6 @@ describe "----- rsmq-worker TESTS -----", -> it "error throw within message processing - Issue #3 (A)", ( done )-> _examplemsg = utils.randomString( utils.randRange( 4, 99 ), 3 ) - _start = Date.now() @timeout( 3000 ) _testFn = ( msg, next, id )-> @@ -118,7 +117,6 @@ describe "----- rsmq-worker TESTS -----", -> it "code error within message processing - Issue #3 (B)", ( done )-> _examplemsg = utils.randomString( utils.randRange( 4, 99 ), 3 ) - _start = Date.now() @timeout( 3000 ) _testFn = ( msg, next, id )-> @@ -148,6 +146,50 @@ describe "----- rsmq-worker TESTS -----", -> should.not.exist( err ) return return + + _examplemsg2 = utils.randomString( utils.randRange( 4, 99 ), 3 ) + it "test stop method - Pull #5 stop", ( done )-> + _examplemsg = utils.randomString( utils.randRange( 4, 99 ), 3 ) + @timeout( 6000 ) + + idx = 0 + _testFn = ( msg, next, id )-> + idx++ + if idx <= 1 + should.equal( msg, _examplemsg ) + worker.stop() + worker.send _examplemsg2, 0, ( err )-> + should.not.exist( err ) + return + next() + return + throw new Error( "Got second message" ) + done() + return + + _endFn = ( err, rawmsg )-> + worker.removeListener( "message", _testFn ) + done() + return + + worker.on( "message", _testFn ) + + worker.send _examplemsg, 0, ( err )-> + should.not.exist( err ) + return + + setTimeout( _endFn, 5000 ) + return + + it "test stop method - Pull #5 start", ( done )-> + _testFn = ( msg, next, id )-> + should.equal( msg, _examplemsg2 ) + done() + return + + worker.on( "message", _testFn ) + worker.start() + return return return