← Documentation Index

NAME

Test::Mailmunge::Utils - utility functions for Mailmunge unit tests

ABSTRACT

Test::Mailmunge::Utils defines a number of utility functions in the main package that are useful for unit tests.

SYNOPSIS

    use Test::Mailmunge::Utils;
    my $ctx = make_test_context();

FUNCTIONS

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.

make_test_context()

Returns a Mailmunge::Context object useful for tests.

start_multiplexor($dir, $filter)

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

stop_multiplexor($dir)

Stops the instance of mailmunge-multiplexor that was started by start_multiplexor($dir, $filter).

mm_mx_ctrl($cmd, $arg1, $arg2...)

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.

write_commands_file($dir, $ctx)

Writes a COMMANDS file in $dir that (when read by the running filter) will recreate $ctx.

set_context_fields_from_msg($ctx, $entity)

Given a MIME::Entity $entity, sets the fields sender, subject and message_id on $ctx based on $entity.

parse_and_copy_msg($output_dir, $input_msg)

Given a file $input_msg containing an RFC5322 mail message, copy the file to "$output_dir/INPUTMSG" and parse it. Return the MIME::Entity resulting from parsing the message,

This method also creates a HEADERS file in $output_dir.

AUTHOR

Dianne Skoll <dianne@skollsoft.com>

LICENSE

This code is licensed under the terms of the GNU General Public License, version 2.

Copyright © 2021 Skoll Software Consulting