Don't capture 'Hive' if it exists in aerohive AP model name

This commit is contained in:
Eric A. Miller
2018-05-06 09:32:35 -04:00
parent 7e0ef60e24
commit 0ab688964f
2 changed files with 8 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ sub model {
my $aerohive = shift;
my $descr = $aerohive->description();
if ( $descr =~ m/\b((Hive|)AP\d+)\b/ix ) {
if ( $descr =~ m/\b(?:Hive|)(AP\d+)\b/ix ) {
return $1;
}
return;

View File

@@ -116,11 +116,16 @@ sub os_ver : Tests(3) {
is($test->{info}->os_ver(), undef, q(No description returns undef os_ver));
}
sub model : Tests(3) {
sub model : Tests(4) {
my $test = shift;
can_ok($test->{info}, 'model');
is($test->{info}->model(), 'AP121', q(Model is expected value));
is($test->{info}->model(),
'AP121', q(Model with 'Hive' in description sting is expected value));
$test->{info}{_description} = 'AP250, HiveOS 8.3r2 build-191018';
is($test->{info}->model(),
'AP250', q(Model without 'Hive' in description sting is expected value));
$test->{info}->clear_cache();
is($test->{info}->model(), undef, q(No description returns undef model));