diff options
author | Jonathan "Duke" Leto <jonathan@leto.net> | 2011-01-12 13:31:51 -0500 |
---|---|---|
committer | Jonathan "Duke" Leto <jonathan@leto.net> | 2011-01-12 13:31:51 -0500 |
commit | c16d34fa7b67ad1e5db7a098e74c5f711e222403 (patch) | |
tree | ec34bcb210fa05caccf8738ae10ccdcfe3867269 | |
parent | Add some tests for jitterbug::Emailer (diff) | |
download | jitterbug-c16d34fa7b67ad1e5db7a098e74c5f711e222403.tar.gz |
Fix some bugs in jitterbug::Emailer and add mocked test data
-rw-r--r-- | lib/jitterbug/Emailer.pm | 6 | ||||
-rw-r--r-- | t/006_emailer.t | 16 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/jitterbug/Emailer.pm b/lib/jitterbug/Emailer.pm index 95bda0d..648c72f 100644 --- a/lib/jitterbug/Emailer.pm +++ b/lib/jitterbug/Emailer.pm @@ -21,14 +21,16 @@ sub run { my $buildconf = $self->{'conf'}->{'jitterbug'}{'build_process'}; my $project = $task->project->name; my $tap_output = $self->{'tap_output'}; - my $sha1 = $task->commit->sha256; + my $desc = JSON::decode_json( $task->commit->content ); + my $email = $desc->{'author'}{'email'}; + my $body = <<BODY; $tap_output BODY Email::Stuff->from($buildconf->{'on_failure_from_email'}) - ->to($buildconf->{'on_failure_to_email'}) + ->to($email) ->cc($buildconf->{'on_failure_cc_email'}) ->text_body($body) ->subject( diff --git a/t/006_emailer.t b/t/006_emailer.t index cc343d1..2df25f1 100644 --- a/t/006_emailer.t +++ b/t/006_emailer.t @@ -2,12 +2,24 @@ use strict; use warnings; use Test::Most tests => 3; use Data::Dumper; +use Test::MockObject; use_ok "jitterbug::Emailer"; { - my $conf = { foo => 'bar' }; - my $task = {}; + my $conf = { jitterbug => { build_process => 'bar'} }; + my $commit = Test::MockObject->new; + my $project = 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' } ); + + $task->mock('commit', sub { $commit }); + $task->mock('project', sub { $project }); + my $tap = "1..1\nok 1\n"; my $e = jitterbug::Emailer->new($conf, $task, $tap); |