Skip to content

Commit 2faaba8

Browse files
author
Kevin Paulisse
committed
Finish spec tests for error messages
1 parent b60d6f4 commit 2faaba8

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

spec/octocatalog-diff/tests/catalog_spec.rb

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,16 +505,87 @@
505505

506506
context 'with compilation directory specified and matching' do
507507
it 'should strip compilation directory' do
508+
allow(@test_obj).to receive(:compilation_dir)
509+
.and_return('/var/folders/dw/foo/environments/production')
510+
obj = {
511+
source: {
512+
'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp',
513+
'line' => 23,
514+
'type' => 'Baz',
515+
'title' => 'buzz'
516+
},
517+
target_type: 'Foo',
518+
target_value: 'bar'
519+
}
520+
result = @test_obj.send(:format_missing_references, [obj])
521+
expect(result).to eq('baz[buzz](/modules/foo/manifests/bar.pp:23) -> foo[bar]')
508522
end
509523
end
510524

511525
context 'with compilation directory specified and not matching' do
512526
it 'should not strip compilation directory' do
527+
allow(@test_obj).to receive(:compilation_dir)
528+
.and_return('/var/folders/dw/bar/environments/production')
529+
obj = {
530+
source: {
531+
'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp',
532+
'line' => 23,
533+
'type' => 'Baz',
534+
'title' => 'buzz'
535+
},
536+
target_type: 'Foo',
537+
target_value: 'bar'
538+
}
539+
result = @test_obj.send(:format_missing_references, [obj])
540+
expect(result).to eq('baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> foo[bar]')
513541
end
514542
end
515543

516544
context 'with compilation directory not specified' do
517545
it 'should not strip compilation directory' do
546+
allow(@test_obj).to receive(:compilation_dir).and_return(nil)
547+
obj = {
548+
source: {
549+
'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp',
550+
'line' => 23,
551+
'type' => 'Baz',
552+
'title' => 'buzz'
553+
},
554+
target_type: 'Foo',
555+
target_value: 'bar'
556+
}
557+
result = @test_obj.send(:format_missing_references, [obj])
558+
expect(result).to eq('baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> foo[bar]')
559+
end
560+
end
561+
562+
context 'with multiple targets for the same resource' do
563+
it 'should display each target separately' do
564+
allow(@test_obj).to receive(:compilation_dir).and_return(nil)
565+
src = {
566+
'file' => '/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp',
567+
'line' => 23,
568+
'type' => 'Baz',
569+
'title' => 'buzz'
570+
}
571+
obj = [
572+
{
573+
source: src,
574+
target_type: 'Foo',
575+
target_value: 'bar'
576+
},
577+
{
578+
source: src,
579+
target_type: 'Fizz',
580+
target_value: 'buzz'
581+
}
582+
]
583+
answer = [
584+
'baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> foo[bar]',
585+
'baz[buzz](/var/folders/dw/foo/environments/production/modules/foo/manifests/bar.pp:23) -> fizz[buzz]'
586+
].join('; ')
587+
result = @test_obj.send(:format_missing_references, obj)
588+
expect(result).to eq(answer)
518589
end
519590
end
520591
end

0 commit comments

Comments
 (0)