Test::Mailmunge::Utils − utility functions for Mailmunge unit tests
Test::Mailmunge::Utils defines a number of utility functions in the main package that are useful for unit tests.
use
Test::Mailmunge::Utils;
my $ctx = make_test_context();
Note that the functions will be documented very briefly. Since they are of use to people writing unit tests, you should examine the source code for more details.
Returns a "Mailmunge::Context" object useful for tests.
Returns an array of lines logged by the filter. Each element of the array is a 3−element array consisting of [queue_id, log_level, message].
Starts "mailmunge−multiplexor" with the spool directory set to $dir and the filter file set to $filter. Note that this will fail if you are running as root, so don't do that.
Sets the socket to "$dir/mx.sock"
Stops the instance of "mailmunge−multiplexor" that was started by "start_multiplexor($dir, $filter)".
Runs "mm_mx_ctrl" with the specified command and arguments. On success, returns the output of "mm−mx−ctrl". On failure, returns the empty string.
Writes a COMMANDS file in $dir that (when read by the running filter) will recreate $ctx.
Given a MIME::Entity $entity, sets the fields "sender", "subject" and "message_id" on $ctx based on $entity.
Given a file $input_msg containing an RFC5322 mail message, copy the file to "$output_dir/INPUTMSG" and parse it. Returns a new "Mailmunge::Context" object whose "mime_entity" field is the parsed message. Other fields in the context object are set as follows:
"sender" is set to the value of the "Return−Path" header, if any.
"subject" is set to the value of the "Subject" header, if any.
"message_id" is set to the value of the "Message−Id" header, if any.
If you supply $new_subject, then the literal text "__SUBJECT__" in the message body is replaced with the value of $new_subject.
This method also creates the HEADERS and PRISTINE_HEADERS files in $output_dir.
Returns 1 if DNS appears to be available, 0 otherwise.
Dianne Skoll <[email protected]>
This code is licensed under the terms of the GNU General Public License, version 2.