From 0bd93a4a94376919c14726124fa0462ae62889d1 Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Tue, 24 Nov 2020 17:00:06 -0500 Subject: [PATCH] A Test for A switch can't override switch group values using default switch group values Issue #5998 --- t/unittest/ConfigStore/Switch.t | 96 +++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/t/unittest/ConfigStore/Switch.t b/t/unittest/ConfigStore/Switch.t index 24c237e58cd2..c2c3dabd5a7b 100644 --- a/t/unittest/ConfigStore/Switch.t +++ b/t/unittest/ConfigStore/Switch.t @@ -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"); @@ -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