diff options
Diffstat (limited to 't')
-rw-r--r-- | t/fixtures/always-allowed | 14 | ||||
-rw-r--r-- | t/fixtures/always-allowed.expected | 14 | ||||
-rw-r--r-- | t/lib.t | 23 |
3 files changed, 42 insertions, 9 deletions
diff --git a/t/fixtures/always-allowed b/t/fixtures/always-allowed new file mode 100644 index 0000000..b383d1a --- /dev/null +++ b/t/fixtures/always-allowed @@ -0,0 +1,14 @@ +Return-Path: <test@mta.example.com>
+Delivered-To: spamcat@example.com
+Received: from mta.example.com
+ by mta.example.com (Dovecot) with LMTP id 9DDcI25oblTvgAEAQc1eRg
+ for <spamcat@example.com>; Thu, 20 Nov 2014 17:17:18 -0500
+Received: by mta.example.com (Postfix, from userid 1001)
+ id 844956F1EE; Thu, 20 Nov 2014 17:17:18 -0500 (EST)
+To: always-allowed@spamcat.example.com
+Subject: test
+Message-Id: <always-allowed@mta.example.com>
+Date: Thu, 20 Nov 2014 17:17:18 -0500 (EST)
+From: sender@example.com (Spamcat Sender)
+
+Sample email.
diff --git a/t/fixtures/always-allowed.expected b/t/fixtures/always-allowed.expected new file mode 100644 index 0000000..b383d1a --- /dev/null +++ b/t/fixtures/always-allowed.expected @@ -0,0 +1,14 @@ +Return-Path: <test@mta.example.com>
+Delivered-To: spamcat@example.com
+Received: from mta.example.com
+ by mta.example.com (Dovecot) with LMTP id 9DDcI25oblTvgAEAQc1eRg
+ for <spamcat@example.com>; Thu, 20 Nov 2014 17:17:18 -0500
+Received: by mta.example.com (Postfix, from userid 1001)
+ id 844956F1EE; Thu, 20 Nov 2014 17:17:18 -0500 (EST)
+To: always-allowed@spamcat.example.com
+Subject: test
+Message-Id: <always-allowed@mta.example.com>
+Date: Thu, 20 Nov 2014 17:17:18 -0500 (EST)
+From: sender@example.com (Spamcat Sender)
+
+Sample email.
@@ -1,6 +1,6 @@ # -*- Mode: cperl -*- -use Test::More tests => 42; +use Test::More tests => 46; use strict; use warnings; @@ -66,18 +66,23 @@ test_file('wrongdomain', 1); test_file('nosubj', 1); test_file('bar', 0); +$sch->set_count('always-allowed', -1); +test_file('always-allowed', 1); + ok(SpamCat->can('get_table')); my @rows = @{$sch->get_table()}; -is($#rows, 3); +is($#rows, 4); @rows = sort { $a->{sender} cmp $b->{sender} } @rows; -is($rows[0]->{sender}, 'bar'); -is($rows[0]->{count}, 0); -is($rows[1]->{sender}, 'foo'); -is($rows[1]->{count}, 16); -is($rows[2]->{sender}, 'name1'); -is($rows[2]->{count}, 20); -is($rows[3]->{sender}, 'nosubj'); +is($rows[0]->{sender}, 'always-allowed'); +is($rows[0]->{count}, -1); +is($rows[1]->{sender}, 'bar'); +is($rows[1]->{count}, 0); +is($rows[2]->{sender}, 'foo'); +is($rows[2]->{count}, 16); +is($rows[3]->{sender}, 'name1'); is($rows[3]->{count}, 20); +is($rows[4]->{sender}, 'nosubj'); +is($rows[4]->{count}, 20); sub test_file { my ($filen, $should_exist) = @_; |