Skip to content

Commit

Permalink
A Test for A switch can't override switch group values using default …
Browse files Browse the repository at this point in the history
…switch group values Issue #5998
  • Loading branch information
jrouzierinverse authored and satkunas committed Dec 10, 2020
1 parent 6020c0b commit 0bd93a4
Showing 1 changed file with 55 additions and 41 deletions.
96 changes: 55 additions & 41 deletions t/unittest/ConfigStore/Switch.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BEGIN {
use setup_test_config;
}

use Test::More tests => 9;
use Test::More tests => 10;
use Utils;
use pf::ConfigStore::Switch;
my ($fh, $filename) = Utils::tempfileForConfigStore("pf::ConfigStore::Switch");
Expand Down Expand Up @@ -51,47 +51,61 @@ my $oldVoiceVlan = $old->{voiceVlan};
}

is($new->{voiceVlan}, $oldVoiceVlan, "delete inherited values");
{
my $cs = pf::ConfigStore::Switch->new;
is_deeply(
[$cs->parentSections('id', {group => 'bob'})],
['group bob', 'default'],
"",
);

is_deeply(
[$cs->parentSections('default', {group => 'bob'})],
[],
"parentSections of default section"
);

is_deeply(
[$cs->parentSections('default' )],
[],
);

is_deeply(
[$cs->parentSections('bob', {group => 'bob'})],
['default'],
);

is_deeply(
[$cs->parentSections('111.1.1.1', {})],
['group bug-5482', 'default'],
"parentSections for bug-5482"
);

is_deeply(
[$cs->parentSections('111.1.1.1', { group => 'bob'})],
['group bob', 'default'],
"parentSections for bug-5482 with defined group"
);

is_deeply(
[$cs->parentSections('bug-5482', { })],
['default'],
"parentSections for bug-5482"
);

}

{
my $cs = pf::ConfigStore::Switch->new;
$cs->update('172.16.8.21', { registrationVlan => 3 });
$cs->commit;
}

my $cs = pf::ConfigStore::Switch->new;
is_deeply(
[$cs->parentSections('id', {group => 'bob'})],
['group bob', 'default'],
"",
);

is_deeply(
[$cs->parentSections('default', {group => 'bob'})],
[],
"parentSections of default section"
);

is_deeply(
[$cs->parentSections('default' )],
[],
);

is_deeply(
[$cs->parentSections('bob', {group => 'bob'})],
['default'],
);

is_deeply(
[$cs->parentSections('111.1.1.1', {})],
['group bug-5482', 'default'],
"parentSections for bug-5482"
);

is_deeply(
[$cs->parentSections('111.1.1.1', { group => 'bob'})],
['group bob', 'default'],
"parentSections for bug-5482 with defined group"
);

is_deeply(
[$cs->parentSections('bug-5482', { })],
['default'],
"parentSections for bug-5482"
);
{
my $cs = pf::ConfigStore::Switch->new;
my $data = $cs->read('172.16.8.21');
is($data->{registrationVlan}, 3);
}

=head1 AUTHOR
Expand Down

0 comments on commit 0bd93a4

Please sign in to comment.