#320 improve duplicate interfaces() fixup
1. sorts the interfaces as they are processed to make A/B testing easier 2. adds the interface index to the original when a duplicate is seen 3. there may be other de-duplication code in vendor modules, untouched
This commit is contained in:
		| @@ -47,9 +47,33 @@ sub setup : Tests(setup) { | ||||
|  | ||||
|   # Start with a common cache that will serve most tests | ||||
|   my $cache_data = { | ||||
|     'store' => {}, | ||||
|     '_i_index' => 1, | ||||
|     '_i_description' => 1, | ||||
|     'store' => { | ||||
|       'i_index' => {1 => 1, 2 => 2, 3 => 3, 4 => 4}, | ||||
|       'i_description' => { | ||||
|         1 => 'Unique Interface Name', | ||||
|         2 => 'Duplicate Interface Name', | ||||
|         3 => 'Duplicate Interface Name' | ||||
|       }, | ||||
|     }, | ||||
|   }; | ||||
|   $test->{info}->cache($cache_data); | ||||
| } | ||||
|  | ||||
| sub duplicates : Tests(2) { | ||||
|   my $test = shift; | ||||
|  | ||||
|   my $expected_data = { | ||||
|     1 => 'Unique Interface Name', | ||||
|     2 => 'Duplicate Interface Name (2)', | ||||
|     3 => 'Duplicate Interface Name (3)', | ||||
|     4 => 4, | ||||
|   }; | ||||
|  | ||||
|   can_ok($test->{info}, 'interfaces'); | ||||
|   cmp_deeply($test->{info}->interfaces(), | ||||
|     $expected_data, 'Call to interfaces() removes duplicates'); | ||||
| } | ||||
|  | ||||
| 1; | ||||
|   | ||||
| @@ -47,9 +47,33 @@ sub setup : Tests(setup) { | ||||
|  | ||||
|   # Start with a common cache that will serve most tests | ||||
|   my $cache_data = { | ||||
|     'store' => {}, | ||||
|     '_i_index' => 1, | ||||
|     '_i_description' => 1, | ||||
|     'store' => { | ||||
|       'i_index' => {1 => 1, 2 => 2, 3 => 3, 4 => 4}, | ||||
|       'i_description' => { | ||||
|         1 => 'Unique Interface Name', | ||||
|         2 => 'Duplicate Interface Name', | ||||
|         3 => 'Duplicate Interface Name' | ||||
|       }, | ||||
|     }, | ||||
|   }; | ||||
|   $test->{info}->cache($cache_data); | ||||
| } | ||||
|  | ||||
| sub duplicates : Tests(2) { | ||||
|   my $test = shift; | ||||
|  | ||||
|   my $expected_data = { | ||||
|     1 => 'Unique Interface Name', | ||||
|     2 => 'Duplicate Interface Name (2)', | ||||
|     3 => 'Duplicate Interface Name (3)', | ||||
|     4 => 4, | ||||
|   }; | ||||
|  | ||||
|   can_ok($test->{info}, 'interfaces'); | ||||
|   cmp_deeply($test->{info}->interfaces(), | ||||
|     $expected_data, 'Call to interfaces() removes duplicates'); | ||||
| } | ||||
|  | ||||
| 1; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user