Skip to content

Commit

Permalink
Add a few more tests and a 'testcover' make target
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Apr 3, 2009
1 parent 45a5265 commit 1ea8e79
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -3,5 +3,8 @@ pm_to_blib
blib/
Makefile
Makefile.[a-z]*

*~
*.bak

cover_db/
11 changes: 10 additions & 1 deletion Makefile.PL
Expand Up @@ -15,7 +15,7 @@ WriteMakefile(
'Time::HiRes' => 0,
},
ABSTRACT => 'Flexible smtpd daemon written in Perl',
AUTHOR => 'Ask Bjorn Hansen <ask@develooper.com>',
AUTHOR => 'Ask Bjoern Hansen <ask@develooper.com>',
EXE_FILES => [qw(qpsmtpd qpsmtpd-forkserver qpsmtpd-prefork qpsmtpd-async)],
);

Expand All @@ -25,3 +25,12 @@ sub MY::libscan {
return $path;
}

sub MY::postamble {
qq[
testcover :
\t cover -delete && \\
HARNESS_PERL_SWITCHES=-MDevel::Cover \$(MAKE) test && \\
cover
]

}
3 changes: 2 additions & 1 deletion t/addresses.t
@@ -1,6 +1,7 @@
use Test::More qw(no_plan);
use Test::More tests => 23;
use strict;
use lib 't';

use_ok('Test::Qpsmtpd');

ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
Expand Down
2 changes: 1 addition & 1 deletion t/helo.t
@@ -1,4 +1,4 @@
use Test::More qw(no_plan);
use Test::More tests => 12;
use strict;
use lib 't';
use_ok('Test::Qpsmtpd');
Expand Down
29 changes: 29 additions & 0 deletions t/misc.t
@@ -0,0 +1,29 @@
use Test::More tests => 14;
use strict;
use lib 't';
use_ok('Test::Qpsmtpd');

ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");

# check_spamhelo plugin
is(($smtpd->command('HELO yahoo.com'))[0], 550, 'HELO yahoo.com');


# fault method
is(($smtpd->command('HELO localhost'))[0], 250, 'HELO localhost');
is(($smtpd->fault)->[0], 451, 'fault returns 451');
is(($smtpd->fault("test message"))->[1],
"Internal error - try again later - test message",
'returns the input message'
);


# vrfy command
is(($smtpd->command('VRFY <foo@bar>'))[0], 252, 'VRFY command');

# plugins/count_unrecognized_commands
is(($smtpd->command('nonsense'))[0], 500, 'bad command 1');
is(($smtpd->command('nonsense'))[0], 500, 'bad command 2');
is(($smtpd->command('nonsense'))[0], 500, 'bad command 3');
is(($smtpd->command('nonsense'))[0], 521, 'bad command 4');

13 changes: 13 additions & 0 deletions t/rset.t
@@ -0,0 +1,13 @@
use Test::More tests => 10;
use strict;
use lib 't';

use_ok('Test::Qpsmtpd');

ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
is(($smtpd->command('EHLO localhost'))[0], 250, 'EHLO localhost');

is(($smtpd->command('MAIL FROM:<ask@perl.org>'))[0], 250, 'MAIL FROM:<ask@perl.org>');
is($smtpd->transaction->sender->address, 'ask@perl.org', 'got the right sender');
is(($smtpd->command('RSET'))[0], 250, 'RSET');
is($smtpd->transaction->sender, undef, 'No sender stored after rset');

0 comments on commit 1ea8e79

Please sign in to comment.