File: 10-synopsis-pass.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 (44 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (4)
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
35
36
37
38
39
40
41
42
43
44
#!perl
use strict;
use warnings;
use Test::More;
use lib "t/lib";
use Utils;


plan tests => 7;

my $module = "SNMP::Extension::PassPersist";

# input data
my ($oid, $type, $value) = qw<.1.2.3 integer 42>;
my $input = "";
my @args  = (-g => $oid);

# expected data
my %expected_tree = (
    $oid => [ $type => $value ],
);
my $expected_output = join "\n", $oid, $type, $value, "";

# load the module
use_ok($module);

# create the object
my $extsnmp = eval { $module->new };
is( $@, "", "$module->new" );
isa_ok( $extsnmp, $module, "check that \$extsnmp" );

# add an OID entry
eval { $extsnmp->add_oid_entry($oid, $type, $value) };
is( $@, "", "add_oid_entry('$oid', '$type', '$value')" );
is_deeply( $extsnmp->oid_tree, \%expected_tree, "check internal OID tree consistency" );

# execute the main loop
local @ARGV = @args;
my ($stdin, $stdout) = ( ro_fh(\$input), wo_fh(\my $output) );
$extsnmp->input($stdin);
$extsnmp->output($stdout);
eval { $extsnmp->run };
is( $@, "", "\$extsnmp->run" );
is( $output, $expected_output, "check the output" );