Add more tests
authorHeiko Schlittermann <hs@schlittermann.de>
Thu, 02 Jun 2016 22:17:27 +0200
changeset 68 8bc711bdd180
parent 67 da29842506b4
child 69 0f66e8a1364a
Add more tests
lib/Exim/Grey.pm
t/00-basic.t
--- a/lib/Exim/Grey.pm	Thu Jun 02 20:12:33 2016 +0200
+++ b/lib/Exim/Grey.pm	Thu Jun 02 22:17:27 2016 +0200
@@ -24,8 +24,6 @@
     db    => 'seen',
 );
 
-sub unseen;
-
 # some helper functions
 sub getDBDir();
 sub findExim(;$);
--- a/t/00-basic.t	Thu Jun 02 20:12:33 2016 +0200
+++ b/t/00-basic.t	Thu Jun 02 22:17:27 2016 +0200
@@ -1,3 +1,22 @@
+use strict;
+use warnings;
 use Test::More qw(no_plan);
+use File::Temp;
 
-use_ok 'Exim::Grey' => qw(unseen);
+use_ok 'Exim::Grey' => qw(unseen)
+  or BAIL_OUT;
+
+my $db = File::Temp->new();
+
+is unseen('a->b', 1, "$db"), 'yes' => 'unseen a->b';
+is unseen('a->b', 1, "$db"), 'yes' => 'unseen a->b';
+
+is unseen('x->y/1.1.1.1', 1, "$db"), 'yes' => 'unseen x->y/1.1.1.1';
+is unseen('x->y/1.1.1.1', 1, "$db"), 'yes' => 'unseen x->y/1.1.1.1';
+
+# sleep
+is unseen('a->b',     0, "$db"), 'no' => 'seen a->b';
+is unseen('x->y/1.1.1.1', 0, "$db"), 'no' => 'seen x->y/1.1.1.1';
+is unseen('x->z/1.1.1.1', 0, "$db"), 'no' => 'seen x->z/1.1.1.1';
+
+is unseen('a->b', 600, "$db"), 'yes' => 'unseen a->b with 600s delay';