aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/bin.t14
-rwxr-xr-xt/delivert2
-rw-r--r--t/lib.t15
3 files changed, 21 insertions, 10 deletions
diff --git a/t/bin.t b/t/bin.t
index 41a82c2..b27e994 100644
--- a/t/bin.t
+++ b/t/bin.t
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use Test::More tests => 1;
@@ -7,14 +7,12 @@ use IO::File;
use strict;
use warnings;
-system "/usr/bin/env > /tmp/fpp";
-
my $spamcat = 'bin/spamcat';
my $conffile = 't/fixtures/sample.conf';
# Add testlib which has createdb and possibly population of said db.
-my @dumpconfig = `$spamcat -c t/fixtures/sample.conf --dumpconfig`;
+my @dumpconfig = `$spamcat -c t/fixtures/sample.conf dumpconfig`;
my %got = parse_configdump(@dumpconfig);
my %expected = (DBPATH => '/tmp/spamcat.sqlite3',
DEFAULT_COUNT => 10,
@@ -22,10 +20,10 @@ my %expected = (DBPATH => '/tmp/spamcat.sqlite3',
DOMAINS => "spamcat.example.com, spamcat2.example.com, spamcat3");
is_deeply(\%got, \%expected);
-# Test for proper delivery.
-my $fh = IO::File->new("|$spamcat -c $conffile") ||
- die "Couldn't open pipe to $spamcat: $!\n";
-$fh->close;
+# TODO: Test for proper exit codes.
+#my $fh = IO::File->new("|$spamcat -c $conffile") ||
+# die "Couldn't open pipe to $spamcat: $!\n";
+#$fh->close;
sub parse_configdump {
my %rc;
diff --git a/t/delivert b/t/delivert
index 63c3864..794e0a1 100755
--- a/t/delivert
+++ b/t/delivert
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use Email::Simple;
use IO::File;
diff --git a/t/lib.t b/t/lib.t
index 21e1c09..1f32c08 100644
--- a/t/lib.t
+++ b/t/lib.t
@@ -1,6 +1,6 @@
# -*- Mode: cperl -*-
-use Test::More tests => 31;
+use Test::More tests => 41;
use strict;
use warnings;
@@ -63,6 +63,19 @@ test_file('wrongdomain', 1);
test_file('nosubj', 1);
test_file('bar', 0);
+ok(SpamCat->can('get_table'));
+my @rows = @{$sch->get_table()};
+is($#rows, 3);
+@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[3]->{count}, 20);
+
sub test_file {
my ($filen, $should_exist) = @_;