From: Chris Nehren Date: Sun, 4 Sep 2011 05:13:47 +0000 (-0400) Subject: simple tests for lists X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=418e2ac2e80483591d2a417a40a8d9bf9e799c38;p=p5sagit%2FPromulger.git simple tests for lists --- diff --git a/t/list.t b/t/list.t new file mode 100644 index 0000000..00a87c9 --- /dev/null +++ b/t/list.t @@ -0,0 +1,83 @@ +#!/usr/bin/perl +use strictures 1; +use autodie; + +use File::Temp (); +use Path::Class; +use Test::Most; + +use aliased 'Promulger::List'; +# no alias here so we don't risk colliding with perl's own Config.pm -- apeiron, +# 2011-09-04 +use Promulger::Config; + +{ + my $raw_pmg_home = File::Temp->newdir; + my $pmg_home = dir($raw_pmg_home); + + my $aliases = $pmg_home->file('aliases'); + my $aliases_fh = $aliases->openw; + close $aliases_fh; + + my $list_home = $pmg_home->subdir('lists'); + $list_home->mkpath; + + my $config_file = $pmg_home->file('pmg.conf'); + my $config_fh = $config_file->openw; + print $config_fh <<"CONFIG"; +mailer = Test +aliases = $aliases +list_home = $list_home +CONFIG + + close $config_fh; + my $config = Promulger::Config->load_config($config_file); + my $list; + lives_ok { $list = List->new( + listname => 'foo', + active => 1, + subscribers => {}, + ) } "can create a list"; + lives_ok { $list->setup } "can setup a list"; + + cmp_ok( + $list->listname, + 'eq', + 'foo', + "list has same listname as one we specified", + ); + cmp_ok( + $list->active, + '==', + 1, + "list is active, like the one we specified", + ); + cmp_deeply( + $list->subscribers, + {}, + "list has no subscribers for now, like the one we specified", + ); + + my $resolved_list = List->resolve('foo'); + cmp_ok( + $resolved_list->listname, + 'eq', + 'foo', + "resolved list has same listname as one we created", + ); + cmp_ok( + $resolved_list->active, + '==', + 1, + "resolved list is active, like the one we created", + ); + cmp_deeply( + $resolved_list->subscribers, + {}, + "resolved list has no subscribers for now, like the one we created", + ); + + lives_ok { $list->subscribe('foo@example.com') } "can subscribe someone"; +} + +done_testing;