File: 12-run.t

package info (click to toggle)
libsnmp-extension-passpersist-perl 0.07-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 216 kB
  • ctags: 68
  • sloc: perl: 776; makefile: 8
file content (34 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!perl
use strict;
use warnings;
use Test::More;
use lib "t/lib";
use SNMP::Extension::PassPersist;


my $module = "SNMP::Extension::PassPersist";
my $common_part = "fatal: An error occurred while executing the backend";
my @cases  = (
    {
        attr => [ backend_init => sub { die "Plonk" } ],
        args => [],
        diag => qr/^$common_part initialisation callback: Plonk/,
    },
    {
        attr => [ backend_collect => sub { die "Plonk" } ],
        args => [],
        diag => qr/^$common_part collecting callback: Plonk/,
    },
);

plan tests => ~~@cases;

for my $case (@cases) {
    my $attr = $case->{attr};
    my $args = $case->{args};
    my $diag = $case->{diag};
    my $object = $module->new(@$attr);
    eval { $object->run() };
    like( $@, $diag, "\$object->run() with \@ARGV=(".join(", ", @$args).")" );
}