From f67531bad2b0aaebfea7ec63922290f28e86d6ab Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 27 Dec 2007 14:36:45 +0000 Subject: r3304@rfc-1918: dakkar | 2007-12-27 13:19:58 +0100 prepraering fro branching --- t/06-age.t | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 t/06-age.t (limited to 't/06-age.t') diff --git a/t/06-age.t b/t/06-age.t new file mode 100644 index 0000000..0d47c5e --- /dev/null +++ b/t/06-age.t @@ -0,0 +1,34 @@ +# -*- mode: cperl -*- +use Test::More tests=>3; +use File::Temp 'tempdir'; + +my $basetime; + +BEGIN { +*CORE::GLOBAL::time=sub{$basetime}; +} + +use DAKKAR::Graylister; + +no warnings 'redefine'; + +my $dbdir=tempdir(CLEANUP=>1); + +local $ENV{SMTPMAILFROM}='gino'; +local $ENV{SMTPRCPTTO}='pino'; +local $ENV{TCPREMOTEIP}='10.1.2.3'; +local $ENV{DAKGL_DBNAME}="$dbdir/gray5.db"; +my ($host,$from,$to)=DAKKAR::Graylister::get_from_env(); + +$basetime=10; + +ok(!DAKKAR::Graylister::is_second_attempt($host,$from,$to),'first attempt'); +DAKKAR::Graylister::record_first_attempt($host,$from,$to); +ok(DAKKAR::Graylister::is_second_attempt($host,$from,$to),'second attempt'); + +$basetime=90000; + +DAKKAR::Graylister::remove_old_attempts(); + +ok(!DAKKAR::Graylister::is_second_attempt($host,$from,$to),'aged attempt'); + -- cgit v1.2.3