|
1414 | 1414 | fileref = { 'file' => '/var/tmp/foo', 'line' => 5 }
|
1415 | 1415 | expect(result[0]).to eq(['!', "Class\fOpenssl::Package\fparameters\fcommon-array", [1, 2, 3], [1, 5, 25], fileref, fileref])
|
1416 | 1416 | end
|
| 1417 | + |
| 1418 | + it 'should return array with proper results for deeply nested arrays of hashes' do |
| 1419 | + hashdiff_add_remove = [ |
| 1420 | + "Class\fOpenssl::Package\fparameters\fobject\farray[0]\fcommon-array" |
| 1421 | + ] |
| 1422 | + |
| 1423 | + empty_puppet_catalog_json = File.read(OctocatalogDiff::Spec.fixture_path('catalogs/catalog-empty.json')) |
| 1424 | + empty_puppet_catalog = OctocatalogDiff::Catalog.create(json: empty_puppet_catalog_json) |
| 1425 | + obj = OctocatalogDiff::CatalogDiff::Differ.new({}, empty_puppet_catalog, empty_puppet_catalog) |
| 1426 | + |
| 1427 | + arr1 = [ |
| 1428 | + { |
| 1429 | + 'name' => 'test', 'value' => 'abc' |
| 1430 | + }, |
| 1431 | + { |
| 1432 | + 'name' => 'test2', 'value' => 'def' |
| 1433 | + } |
| 1434 | + ] |
| 1435 | + cat1 = [ |
| 1436 | + { |
| 1437 | + 'type' => 'Class', |
| 1438 | + 'title' => 'Openssl::Package', |
| 1439 | + 'parameters' => { |
| 1440 | + 'object' => { |
| 1441 | + 'array' => [ |
| 1442 | + { |
| 1443 | + 'common-array' => arr1 |
| 1444 | + } |
| 1445 | + ] |
| 1446 | + } |
| 1447 | + }, |
| 1448 | + 'file' => '/var/tmp/foo', |
| 1449 | + 'line' => 5 |
| 1450 | + } |
| 1451 | + ] |
| 1452 | + |
| 1453 | + arr2 = [ |
| 1454 | + { |
| 1455 | + 'name' => 'test', 'value' => 'abc' |
| 1456 | + }, |
| 1457 | + { |
| 1458 | + 'name' => 'test2', 'value' => 'def' |
| 1459 | + }, |
| 1460 | + { |
| 1461 | + 'name' => 'test3', 'value' => 'ghj' |
| 1462 | + } |
| 1463 | + ] |
| 1464 | + cat2 = [ |
| 1465 | + { |
| 1466 | + 'type' => 'Class', |
| 1467 | + 'title' => 'Openssl::Package', |
| 1468 | + 'parameters' => { |
| 1469 | + 'object' => { |
| 1470 | + 'array' => [ |
| 1471 | + { |
| 1472 | + 'common-array' => arr2 |
| 1473 | + } |
| 1474 | + ] |
| 1475 | + } |
| 1476 | + }, |
| 1477 | + 'file' => '/var/tmp/foo', |
| 1478 | + 'line' => 5 |
| 1479 | + } |
| 1480 | + ] |
| 1481 | + |
| 1482 | + remaining1 = obj.send(:resources_as_hashes_with_serialized_keys, cat1) |
| 1483 | + remaining2 = obj.send(:resources_as_hashes_with_serialized_keys, cat2) |
| 1484 | + |
| 1485 | + result = obj.send(:hashdiff_nested_changes, hashdiff_add_remove, remaining1, remaining2) |
| 1486 | + expect(result).to be_a_kind_of(Array) |
| 1487 | + expect(result.size).to eq(1) |
| 1488 | + |
| 1489 | + fileref = { 'file' => '/var/tmp/foo', 'line' => 5 } |
| 1490 | + expect(result[0]).to eq(['!', "Class\fOpenssl::Package\fparameters\fobject\farray[0]\fcommon-array", arr1, arr2, fileref, fileref]) |
| 1491 | + end |
1417 | 1492 | end
|
1418 | 1493 |
|
1419 | 1494 | describe '#regexp_operator_match?' do
|
|
0 commit comments