New unit testing with nodeunit and a log.syslog change#164
Merged
baudehlo merged 10 commits intoharaka:masterfrom Feb 22, 2012
Merged
New unit testing with nodeunit and a log.syslog change#164baudehlo merged 10 commits intoharaka:masterfrom
baudehlo merged 10 commits intoharaka:masterfrom
Conversation
stubs out some of the objects we're going to need in plugins. Finally, I implement unit tests for one of the smallest plugins we have, relay_all.
Collaborator
There was a problem hiding this comment.
Couldn't you just add in:
ini.general ||= {};
Collaborator
Author
There was a problem hiding this comment.
This passes tests and is more clear.
baudehlo
added a commit
that referenced
this pull request
Feb 22, 2012
New unit testing with nodeunit and a log.syslog change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've added a git submodule of nodeunit to haraka, and two tests for relay_all and log.syslog plugins so that people can get an idea of how to test with nodeunit. There will be many more test to come in the future, both for plugins and core modules.
I've also added some helpful code for testing in function-bind.js. This should allow one to modify anonymous functions in haraka, or in tests, with .bind(this), thus scoping the caller's 'this' object to the anonymous function.
When testing plugins, core modules are usually stubbed out due to the more complex nature of how haraka runs plugins. While not all core module stubs are present or even complete, I do expect we will fill them out as needed.
To run these tests simply type ./run_tests from the haraka root. If the submodules are not yet installed it will prompt you to run the two submodule commands: 'git submodule init' and 'git submodule update'. One only has to do this once to get the submodule.
The nodeunit submodule is pulled from a slightly hacked version of nodeunit I made to add a bunch of additional asserts. I've submitted these changes to the nodeunit author as a pull request in the hopes that we can simply submodule the mainline nodeunit in the future. One can see the pull request here:
caolan/nodeunit#153