summaryrefslogtreecommitdiff
path: root/t/006_emailer.t
diff options
context:
space:
mode:
authorJonathan "Duke" Leto <jonathan@leto.net>2011-01-12 10:56:48 -0800
committerJonathan "Duke" Leto <jonathan@leto.net>2011-01-12 10:56:48 -0800
commitb2fe2456e476962c19cceb74b1d17fb0f22c3c3e (patch)
treec06b3412b7cbbad799a012953771fd1484feee8e /t/006_emailer.t
parentAdd Test::MockObject as a dep (diff)
downloadjitterbug-b2fe2456e476962c19cceb74b1d17fb0f22c3c3e.tar.gz
More tests for jitterbug::Emailer
Diffstat (limited to 't/006_emailer.t')
-rw-r--r--t/006_emailer.t25
1 files changed, 19 insertions, 6 deletions
diff --git a/t/006_emailer.t b/t/006_emailer.t
index 2df25f1..0dce025 100644
--- a/t/006_emailer.t
+++ b/t/006_emailer.t
@@ -1,29 +1,42 @@
use strict;
use warnings;
-use Test::Most tests => 3;
+use Test::Most tests => 5;
use Data::Dumper;
use Test::MockObject;
use_ok "jitterbug::Emailer";
{
- my $conf = { jitterbug => { build_process => 'bar'} };
- my $commit = Test::MockObject->new;
+ my $buildconf = {
+ on_failure_from_email => 'bob@example.com',
+ on_failure_cc_email => 'steve@apple.com',
+ on_failure_subject_prefix => 'BLARG',
+ };
+
+ my $conf = { jitterbug => { build_process => $buildconf } };
+ my $commit = Test::MockObject->new;
my $project = Test::MockObject->new;
- my $task = Test::MockObject->new;
+ my $task = Test::MockObject->new;
$project->mock('name', sub { 'ponie' });
$commit->mock('sha256', sub { 'c0decafe' });
- $commit->mock('content', sub { 'this should be JSON' } );
+ $commit->mock('content', sub { '{ }' } );
$task->mock('commit', sub { $commit });
$task->mock('project', sub { $project });
- my $tap = "1..1\nok 1\n";
+ my $tap = "THIS IS TAP";
my $e = jitterbug::Emailer->new($conf, $task, $tap);
isa_ok($e,'jitterbug::Emailer');
can_ok($e,qw/new run/);
+ $e->run;
+ my $email = $e->{'last_email_sent'}{'email'};
+ like($email->body, qr/THIS IS TAP/, 'email body looks right');
+
+ my $header = $email->{'header'};
+ isa_ok($header, 'Email::MIME::Header');
+
}