--- trunk/t/1_nos.t 2005/05/17 21:37:06 38 +++ trunk/t/1_nos.t 2005/05/18 13:12:54 45 @@ -3,7 +3,7 @@ use strict; use blib; -use Test::More tests => 31; +use Test::More tests => 38; BEGIN { use_ok('Nos') }; @@ -19,14 +19,31 @@ my $i = 0; foreach my $email (qw(foo@example.com bar@example.com baz@example.com)) { - ok($nos->add_member_to_list( list => 'My list', email => $email ), "add_member_to_list $email"); + my $full_name = uc($1)." Doe" if ($email =~ m/^([^@]+)@/); + ok($nos->add_member_to_list( list => 'My list', email => $email, name => $full_name ), "add_member_to_list $email"); ok($nos->add_member_to_list( list => 'another', email => $email ), "add_member_to_list $email") if ($i % 2 == 0); ok($nos->add_member_to_list( list => 'test', email => $email ), "add_member_to_list $email") if ($i % 3 == 0); + $i++; } ok($nos->add_message_to_list( list => 'My list', message => "Subject: test\n\nJust a test\n\n" ), "add_message_to_list"); foreach my $i ( 1 .. 10 ) { - ok($nos->add_message_to_list( list => 'another', message => "Subject: test $i" ), "add_message_to_list"); - ok($nos->add_message_to_list( list => 'test', message => "Subject: test e-mail $i\n\nIsn't life great?\n" ), "add_message_to_list") if ($i % 3 == 0); + ok($nos->add_message_to_list( list => 'another', message => "Subject: test $i" ), "add_message_to_list another $i"); + 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); } + +cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 3, 'members of My list'); +cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 2, 'members of another'); +cmp_ok(scalar $nos->list_members( list => 'test' ), '==', 1, 'members of test'); + +ok($nos->delete_member( email => 'foo@example.com' ), "delete"); + +cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 2, 'members of My list'); +cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 1, 'members of another'); +cmp_ok(scalar $nos->list_members( list => 'test' ), '==', 0, 'members of test'); + +ok($nos->delete_member( name => 'BAZ Doe' ), "delete"); + +cmp_ok(scalar $nos->list_members( list => 'My list' ), '==', 1, 'members of My list'); +cmp_ok(scalar $nos->list_members( list => 'another' ), '==', 0, 'members of another');