omercier 226a574d41
feat(apps::vmware::vsphere8::vcenter::plugin): new plugin (#5608)
Co-authored-by: sdepassio <114986849+sdepassio@users.noreply.github.com>
Refs: CTOR-431
2025-07-04 15:54:02 +02:00

101 lines
3.3 KiB
Perl

use strict;
use warnings;
use Test2::V0;
use Test2::Tools::Compare qw{is like match};
use FindBin;
use lib "$FindBin::RealBin/../../../../src";
use centreon::plugins::misc;
sub test {
my @tests = (
{
string => undef,
include_regexp => undef,
exclude_regexp => undef,
expected_boolean => 1,
msg => 'Test undef string with undef include and exclude regexp'
},
{
string => undef,
include_regexp => 'test',
exclude_regexp => undef,
expected_boolean => 1,
msg => 'Test undef string with non-empty include and undef exclude regexp'
},
{
string => 'test',
include_regexp => undef,
exclude_regexp => undef,
expected_boolean => 0,
msg => 'Test string with undef include and exclude regexp'
},
{
string => 'test',
include_regexp => '^t.*t$',
exclude_regexp => undef,
expected_boolean => 0,
msg => 'Test string with include regexp and undef exclude regexp'
},
{
string => 'test',
include_regexp => undef,
exclude_regexp => '^t.*t$',
expected_boolean => 1,
msg => 'Test string with undef include regex and non-empty exclude regexp'
},
{
string => '',
include_regexp => '',
exclude_regexp => '',
expected_boolean => 0,
msg => 'Test empty string with empty include and exclude regexp'
},
{
string => '',
include_regexp => 'test',
exclude_regexp => '',
expected_boolean => 1,
msg => 'Test empty string with non-empty include and empty exclude regexp'
},
{
string => 'test',
include_regexp => '',
exclude_regexp => '',
expected_boolean => 0,
msg => 'Test string with empty include and exclude regexp'
},
{
string => 'test',
include_regexp => '^t.*t$',
exclude_regexp => '',
expected_boolean => 0,
msg => 'Test string with include regexp and empty exclude regexp'
},
{
string => 'test',
include_regexp => '',
exclude_regexp => '^t.*t$',
expected_boolean => 1,
msg => 'Test string with empty include regex and non-empty exclude regexp'
},
{
string => 'test',
include_regexp => '^t.*t$',
exclude_regexp => '^t.*t$',
expected_boolean => 1,
msg => 'Test string with both include and exclude regexp matching the string'
},
);
for my $test (@tests) {
my $is_excluded = centreon::plugins::misc::is_excluded($test->{string}, $test->{include_regexp}, $test->{exclude_regexp});
is($is_excluded, $test->{expected_boolean}, $test->{msg});
}
}
test();
done_testing();