Skip to content
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
merged 10 commits into from
Feb 22, 2012

Conversation

godsflaw
Copy link
Collaborator

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

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');
Copy link
Collaborator

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 || {};
Copy link
Collaborator Author

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
@baudehlo baudehlo merged commit facca75 into haraka:master Feb 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants