|
532 | 532 | end |
533 | 533 | end |
534 | 534 | end |
| 535 | +end |
535 | 536 |
|
| 537 | +describe OctocatalogDiff::CatalogDiff::Differ do |
536 | 538 | context 'ignoring only adds / removes / changes' do |
537 | 539 | describe '#ignore' do |
538 | 540 | before(:all) do |
|
1279 | 1281 | expect(@logger_str.string).to match(/Exiting filter_diffs_for_absent_files with 7 diffs/) |
1280 | 1282 | end |
1281 | 1283 | end |
| 1284 | + |
| 1285 | + describe '#filter_diffs_for_equivalent_yaml_files' do |
| 1286 | + let(:obj) { described_class.allocate } |
| 1287 | + let(:str1a) { "---\n foo: bar" } |
| 1288 | + let(:str1b) { "---\nfoo: bar" } |
| 1289 | + let(:str2) { "---\n foo: baz" } |
| 1290 | + |
| 1291 | + it 'should not filter out an added resource' do |
| 1292 | + result = [['+', "File\ffoobar.yaml", { 'parameters' => { 'content' => str1a } }]] |
| 1293 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1294 | + expect(result.size).to eq(1) |
| 1295 | + end |
| 1296 | + |
| 1297 | + it 'should not filter out a removed resource' do |
| 1298 | + result = [['-', "File\ffoobar.yaml", { 'parameters' => { 'content' => str1a } }]] |
| 1299 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1300 | + expect(result.size).to eq(1) |
| 1301 | + end |
| 1302 | + |
| 1303 | + it 'should not filter out a non-file resource' do |
| 1304 | + result = [['~', "Exec\ffoobar.yaml\fparameters\fcontent", str1a, str1b]] |
| 1305 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1306 | + expect(result.size).to eq(1) |
| 1307 | + end |
| 1308 | + |
| 1309 | + it 'should not filter out a file whose extension is not .yaml / .yml' do |
| 1310 | + result = [['~', "File\ffoobar.json\fparameters\fcontent", str1a, str1b]] |
| 1311 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1312 | + expect(result.size).to eq(1) |
| 1313 | + end |
| 1314 | + |
| 1315 | + it 'should not filter out a change with no content change' do |
| 1316 | + result = [['~', "File\ffoobar.json\fparameters\fowner", 'root', 'nobody']] |
| 1317 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1318 | + expect(result.size).to eq(1) |
| 1319 | + end |
| 1320 | + |
| 1321 | + it 'should not filter out a change where YAML objects are dissimilar' do |
| 1322 | + result = [['~', "File\ffoobar.yaml\fparameters\fcontent", str1a, str2]] |
| 1323 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1324 | + expect(result.size).to eq(1) |
| 1325 | + end |
| 1326 | + |
| 1327 | + it 'should not filter out a change where YAML is invalid' do |
| 1328 | + x_str = '---{ "blah": "foo" }' |
| 1329 | + result = [['~', "File\ffoobar.yaml\fparameters\fcontent", x_str, x_str]] |
| 1330 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1331 | + expect(result.size).to eq(1) |
| 1332 | + end |
| 1333 | + |
| 1334 | + it 'should not filter out a change where YAML is unparseable' do |
| 1335 | + x_str = "--- !ruby/object:This::Does::Not::Exist\n foo: bar" |
| 1336 | + result = [['~', "File\ffoobar.yaml\fparameters\fcontent", x_str, x_str]] |
| 1337 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1338 | + expect(result.size).to eq(1) |
| 1339 | + end |
| 1340 | + |
| 1341 | + it 'should filter out a whitespace-only change to a .yaml file' do |
| 1342 | + result = [['~', "File\ffoobar.yaml\fparameters\fcontent", str1a, str1b]] |
| 1343 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1344 | + expect(result.size).to eq(0) |
| 1345 | + end |
| 1346 | + |
| 1347 | + it 'should filter out a whitespace-only change to a .yml file' do |
| 1348 | + result = [['~', "File\ffoobar.yml\fparameters\fcontent", str1a, str1b]] |
| 1349 | + obj.send(:filter_diffs_for_equivalent_yaml_files, result) |
| 1350 | + expect(result.size).to eq(0) |
| 1351 | + end |
| 1352 | + end |
1282 | 1353 | end |
0 commit comments