/[notice-sender]/trunk/t/1_nos.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/1_nos.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 31 by dpavlin, Mon May 16 22:04:40 2005 UTC revision 45 by dpavlin, Wed May 18 13:12:54 2005 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use blib;  use blib;
5    
6  use Test::More tests => 5;  use Test::More tests => 38;
7    
8  BEGIN { use_ok('Nos') };  BEGIN { use_ok('Nos') };
9    
10  ok(my $nos = new Nos('dsn' => 'dbi:Pg:dbname=notices'), "new");  ok(my $nos = new Nos('dsn' => 'dbi:Pg:dbname=notices'), "new");
11    
12  ok($nos->_add_list( list => 'My list', email => 'my-list@example.com'), "_add_list");  ok($nos->new_list( list => 'My list', email => 'my-list@example.com'), "new_list my-list");
13    ok($nos->new_list( list => 'another', email => 'another@example.com'), "new_list another");
14    ok($nos->new_list( list => 'test', email => 'test@example.com'), "new_list test");
15    
16    ok($nos->_get_list('My list'), "_get_list");
17    ok($nos->_get_list('another'), "_get_list");
18    ok($nos->_get_list('test'), "_get_list");
19    
20    my $i = 0;
21    foreach my $email (qw(foo@example.com bar@example.com baz@example.com)) {
22            my $full_name = uc($1)." Doe" if ($email =~ m/^([^@]+)@/);
23            ok($nos->add_member_to_list( list => 'My list', email => $email, name => $full_name ), "add_member_to_list $email");
24            ok($nos->add_member_to_list( list => 'another', email => $email ), "add_member_to_list $email") if ($i % 2 == 0);
25            ok($nos->add_member_to_list( list => 'test', email => $email ), "add_member_to_list $email") if ($i % 3 == 0);
26            $i++;
27    }
28    
29    ok($nos->add_message_to_list( list => 'My list', message => "Subject: test\n\nJust a test\n\n" ), "add_message_to_list");
30    
31    foreach my $i ( 1 .. 10 ) {
32            ok($nos->add_message_to_list( list => 'another', message => "Subject: test $i" ), "add_message_to_list another $i");
33            ok($nos->add_message_to_list( list => 'test', message => "Subject: test e-mail $i\n\nIsn't life great?\n" ), "add_message_to_list test $i") if ($i % 3 == 0);
34    }
35    
36    cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 3, 'members of My list');
37    cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 2, 'members of another');
38    cmp_ok(scalar $nos->list_members( list => 'test' ), '==', 1, 'members of test');
39    
40    ok($nos->delete_member( email => 'foo@example.com' ), "delete");
41    
42    cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 2, 'members of My list');
43    cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 1, 'members of another');
44    cmp_ok(scalar $nos->list_members( list => 'test' ), '==', 0, 'members of test');
45    
46  ok($nos->add_member_to_list( list => 'My list', email => 'foo@example.com' ), "add_member_to_list");  ok($nos->delete_member( name => 'BAZ Doe' ), "delete");
47    
48  ok($nos->add_message_to_list( list => 'My list', message => 'Subject: test\nJust a test' ), "add_message_to_list");  cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 1, 'members of My list');
49    cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 0, 'members of another');

Legend:
Removed from v.31  
changed lines
  Added in v.45

  ViewVC Help
Powered by ViewVC 1.1.26