t/10-interface.tt
author Heiko Schlittermann <hs@schlittermann.de>
Wed, 21 Jun 2017 00:26:46 +0200
changeset 73 e2559ee78cb3
parent 72 t/00-basic.t@f095f28db247
permissions -rw-r--r--
[snapshot] working?
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
73
e2559ee78cb3 [snapshot] working?
Heiko Schlittermann <hs@schlittermann.de>
parents: 72
diff changeset
    23
    is seen('x->y/1.1.1.1', 0, "$db"), 'yes' => 'seen x->y/1.1.1.1';
e2559ee78cb3 [snapshot] working?
Heiko Schlittermann <hs@schlittermann.de>
parents: 72
diff changeset
    24
    is seen('x->z/1.1.1.1', 0, "$db"), 'yes' => 'seen x->z/1.1.1.1 (subkey known)';
e2559ee78cb3 [snapshot] working?
Heiko Schlittermann <hs@schlittermann.de>
parents: 72
diff changeset
    25
    is seen('1.1.1.1', 0, "$db"), 'yes' => 'seen 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
};
73
e2559ee78cb3 [snapshot] working?
Heiko Schlittermann <hs@schlittermann.de>
parents: 72
diff changeset
    28
__END__
72
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    29
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    30
subtest 'whitelist multiple subkeys' => sub {
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    31
    my $db = File::Temp->new();
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    32
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    33
    is unseen('x->y/1.1.1.1', 0, "$db"), 'yes' => 'unseen x->y/1.1.1.1';
73
e2559ee78cb3 [snapshot] working?
Heiko Schlittermann <hs@schlittermann.de>
parents: 72
diff changeset
    34
    is unseen('x->y/2.2.2.2', 3, "$db"), 'yes' => 'unseen x->y/3.3.3.3';
e2559ee78cb3 [snapshot] working?
Heiko Schlittermann <hs@schlittermann.de>
parents: 72
diff changeset
    35
    is unseen('x->y/3.3.3.3', 0, "$db"), 'no' => 'not unseen x->y/2.2.2.2';
72
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    36
f095f28db247 Implement auto-history
Heiko Schlittermann <hs@schlittermann.de>
parents: 71
diff changeset
    37
    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
    38
    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
    39
    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
    40
};