Sort keys in globals, funcs, mibs, and munges tests so that reported order is consistent between test runs

This commit is contained in:
Eric A. Miller
2018-03-30 17:06:00 -04:00
parent 5fe0ebaeda
commit eeeabeec94

View File

@@ -118,8 +118,7 @@ sub device_type : Tests(2) {
# This depends on cache or mocked session data being provided. # This depends on cache or mocked session data being provided.
# Recommendation is to extend the existing setup method in the # Recommendation is to extend the existing setup method in the
# subclass to provide the common data. # subclass to provide the common data.
is($test->{info}->device_type(), is($test->{info}->device_type(), $class, qq(Device type is $class));
$class, qq(Device type is $class));
} }
sub globals : Tests(2) { sub globals : Tests(2) {
@@ -130,7 +129,7 @@ sub globals : Tests(2) {
subtest 'Globals can() subtest' => sub { subtest 'Globals can() subtest' => sub {
my $test_globals = $test->{info}->globals; my $test_globals = $test->{info}->globals;
foreach my $key (keys %$test_globals) { foreach my $key (sort (keys %$test_globals)) {
can_ok($test->{info}, $key); can_ok($test->{info}, $key);
} }
}; };
@@ -144,7 +143,7 @@ sub funcs : Tests(2) {
subtest 'Funcs can() subtest' => sub { subtest 'Funcs can() subtest' => sub {
my $test_funcs = $test->{info}->funcs; my $test_funcs = $test->{info}->funcs;
foreach my $key (keys %$test_funcs) { foreach my $key (sort (keys %$test_funcs)) {
can_ok($test->{info}, $key); can_ok($test->{info}, $key);
} }
}; };
@@ -159,7 +158,7 @@ sub mibs : Tests(2) {
my $mibs = $test->{info}->mibs(); my $mibs = $test->{info}->mibs();
foreach my $key (keys %$mibs) { foreach my $key (sort(keys %$mibs)) {
my $qual_name = "$key" . '::' . "$mibs->{$key}"; my $qual_name = "$key" . '::' . "$mibs->{$key}";
ok(defined $SNMP::MIB{$mibs->{$key}}, "$qual_name defined"); ok(defined $SNMP::MIB{$mibs->{$key}}, "$qual_name defined");
like(SNMP::translateObj($qual_name), like(SNMP::translateObj($qual_name),
@@ -176,7 +175,7 @@ sub munge : Tests(2) {
subtest 'Munges subtest' => sub { subtest 'Munges subtest' => sub {
my $test_munges = $test->{info}->munge(); my $test_munges = $test->{info}->munge();
foreach my $key (keys %$test_munges) { foreach my $key (sort(keys %$test_munges)) {
isa_ok($test_munges->{$key}, 'CODE', "$key munge"); isa_ok($test_munges->{$key}, 'CODE', "$key munge");
} }
}; };