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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#!perl
use strict;
use warnings;
use Test2::V0;
use Env::Assert::Functions qw( report_errors :constants );
subtest 'Public Subroutine report_errors()' => sub {
{
my %errors = (
variables => {
USER => {
type => ENV_ASSERT_MISSING_FROM_DEFINITION,
message => 'Variable USER has invalid content',
},
},
);
my $expected = <<'END_OF_TEXT';
Environment Assert: ERRORS:
variables:
USER: Variable USER has invalid content
END_OF_TEXT
my $out = report_errors( \%errors );
is( $out, $expected, 'Errors output correct' );
}
{
my %errors = (
variables => {
USER => {
type => ENV_ASSERT_MISSING_FROM_ENVIRONMENT,
message => 'Variable USER is missing from environment',
},
NEEDLESS_1 => {
type => ENV_ASSERT_MISSING_FROM_DEFINITION,
message => 'Variable NEEDLESS_1 is missing from definition',
},
},
);
my $expected = <<'END_OF_TEXT';
Environment Assert: ERRORS:
variables:
NEEDLESS_1: Variable NEEDLESS_1 is missing from definition
USER: Variable USER is missing from environment
END_OF_TEXT
my $out = report_errors( \%errors );
is( $out, $expected, 'Errors output correct' );
}
{
my %errors = ();
my $expected = <<'END_OF_TEXT';
Environment Assert: ERRORS:
END_OF_TEXT
my $out = report_errors( \%errors );
is( $out, $expected, 'Errors output correct' );
}
done_testing;
};
done_testing;
|