-
-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New unit testing with nodeunit and a log.syslog change #164
Merged
Conversation
This file contains 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
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.
var ndelay = ini.general && (ini.general['log_ndelay'] || 0); | ||
var nowait = ini.general && (ini.general['log_nowait'] || 0); | ||
var options = 0; | ||
var ini = this.config.get('log.syslog.ini'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just add in:
ini.general ||= {};
var nowait = ini.general && (ini.general['log_nowait'] || 0); | ||
var options = 0; | ||
var ini = this.config.get('log.syslog.ini'); | ||
ini.general = ini.general || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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