Skip to content

Commit

Permalink
added tests for pull#5
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Peter committed Nov 4, 2015
1 parent 14faf83 commit 0eb953d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
- "grunt build"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`|
Expand Down
46 changes: 44 additions & 2 deletions _src/test/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 )->
Expand Down Expand Up @@ -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 )->
Expand Down Expand Up @@ -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

0 comments on commit 0eb953d

Please sign in to comment.