t/00-basic.t
author Heiko Schlittermann <hs@schlittermann.de>
Sat, 04 Jun 2016 23:05:29 +0200
changeset 72 f095f28db247
parent 71 46ba051d29bd
permissions -rw-r--r--
Implement auto-history
68
8bc711bdd180 Add more tests
Heiko Schlittermann <hs@schlittermann.de>
parents: 58
diff changeset
     1
use strict;
8bc711bdd180 Add more tests
Heiko Schlittermann <hs@schlittermann.de>
parents: 58
diff changeset
     2
use warnings;
71
46ba051d29bd [perltidy] test
Heiko Schlittermann <hs@schlittermann.de>
parents: 68
diff changeset
     3
58
27440e1334b7 Use lib/ and ExtUtils::MakeMaker
heiko
parents:
diff changeset
     4
use Test::More qw(no_plan);
68
8bc711bdd180 Add more tests
Heiko Schlittermann <hs@schlittermann.de>
parents: 58
diff changeset
     5
use File::Temp;
58
27440e1334b7 Use lib/ and ExtUtils::MakeMaker
heiko
parents:
diff changeset
     6
71
46ba051d29bd [perltidy] test
Heiko Schlittermann <hs@schlittermann.de>
parents: 68
diff changeset
     7
use_ok 'Exim::Grey' => qw(unseen seen) or BAIL_OUT;
68
8bc711bdd180 Add more tests
Heiko Schlittermann <hs@schlittermann.de>
parents: 58
diff changeset
     8
72
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
     9
subtest 'simple' => sub {
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    10
    my $db = File::Temp->new();
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    11
    is seen('a->x', 0, "$db"), 'no' => 'not seen a->x';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    12
    is unseen('a->b', 0,   "$db"), 'yes' => 'unseen a->b';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    13
    is unseen('a->b', 600, "$db"), 'yes' => 'unseen a->b with 600s delay';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    14
    is unseen('a->b', 0,   "$db"), 'no'  => 'not unseen a->b';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    15
    is seen('a->b', 600, "$db"), 'no' => 'not seen a->b with 600s delay';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    16
};
68
8bc711bdd180 Add more tests
Heiko Schlittermann <hs@schlittermann.de>
parents: 58
diff changeset
    17
72
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    18
subtest 'whitelist' => sub {
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    19
    my $db = File::Temp->new();
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    20
    is unseen('x->y/1.1.1.1', 1, "$db"), 'yes' => 'unseen x->y/1.1.1.1';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    21
    is unseen('x->y/1.1.1.1', 1, "$db"), 'yes' => 'unseen x->y/1.1.1.1';
68
8bc711bdd180 Add more tests
Heiko Schlittermann <hs@schlittermann.de>
parents: 58
diff changeset
    22
72
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    23
    is unseen('x->y/1.1.1.1', 0, "$db"), 'no' => 'not unseen x->y/1.1.1.1';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    24
    is unseen('x->z/1.1.1.1', 0, "$db"), 'no' => 'not unseen x->z/1.1.1.1';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    25
    is seen('x->z/1.1.1.1', 0, "$db"), 'yes' => 'seen x->z/1.1.1.1';
68
8bc711bdd180 Add more tests
Heiko Schlittermann <hs@schlittermann.de>
parents: 58
diff changeset
    26
72
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    27
};
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    28
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    29
subtest 'whitelist multiple subkeys' => sub {
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    30
    my $db = File::Temp->new();
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    31
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    32
    is unseen('x->y/1.1.1.1', 0, "$db"), 'yes' => 'unseen x->y/1.1.1.1';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    33
    is unseen('x->y/2.2.2.2', 0, "$db"), 'no' => 'not unseen x->y/2.2.2.2';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    34
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    35
    is unseen('a->b/1.1.1.1', 0, "$db"), 'no' => 'not unseen (whitelisted source)';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    36
    is unseen('a->c/2.2.2.2', 0, "$db"), 'no' => 'not unseen (whitelisted source)';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    37
    is unseen('x->y/3.3.3.3', 0, "$db"), 'no' => 'not unseen x->y/3.3.3.3 (known key)';
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    38
};