#!/usr/bin/env perl use Test::More tests => 3; use IO::File; use strict; use warnings; 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 $conffile dumpconfig`; my %got = parse_configdump(@dumpconfig); my %expected = (DBPATH => '/tmp/spamcat.sqlite3', DEFAULT_COUNT => 10, DELIVER => 't/delivert', DOMAINS => "spamcat.example.com, spamcat2.example.com, spamcat3"); is_deeply(\%got, \%expected); # Unknown senders have the default number of mails left. my @got = `$spamcat -c $conffile get unknown-sender`; is_deeply(\@got, ["unknown-sender has $expected{DEFAULT_COUNT} messages remaining.\n"]); # Missing argument to set fails. my $got = system("$spamcat -c $conffile set missing-argument") >> 8; is_deeply($got, 1); sub parse_configdump { my %rc; while (my $line = shift) { $line =~ /(.*) = (.*)/; $rc{$1} = $2; } %rc; }