@@ -188,6 +188,51 @@ def self.catalog_contains_resource(result, type, title)
188188 end
189189end
190190
191+ describe 'validation of alias references' do
192+ context 'with valid catalog' do
193+ before ( :all ) do
194+ @result = OctocatalogDiff ::Spec . reference_validation_catalog ( 'working-alias' , %w( before require subscribe notify ) )
195+ end
196+
197+ it 'should succeed' do
198+ expect ( @result . exitcode ) . to eq ( 2 )
199+ end
200+
201+ it 'should not raise any exceptions' do
202+ expect ( @result . exception ) . to be_nil , OctocatalogDiff ::Integration . format_exception ( @result )
203+ end
204+
205+ it 'should contain representative resources' do
206+ pending 'Catalog failed' unless @result . exitcode == 2
207+ expect ( OctocatalogDiff ::Spec . catalog_contains_resource ( @result , 'Exec' , 'before alias caller' ) ) . to eq ( true )
208+ expect ( OctocatalogDiff ::Spec . catalog_contains_resource ( @result , 'Exec' , 'before alias target' ) ) . to eq ( true )
209+ expect ( OctocatalogDiff ::Spec . catalog_contains_resource ( @result , 'Exec' , 'the before alias target' ) ) . to eq ( true )
210+ end
211+ end
212+
213+ context 'with broken references' do
214+ before ( :all ) do
215+ @result = OctocatalogDiff ::Spec . reference_validation_catalog ( 'broken-alias' , %w( before require subscribe notify ) )
216+ end
217+
218+ it 'should not succeed' do
219+ expect ( @result . exitcode ) . to eq ( -1 ) , OctocatalogDiff ::Integration . format_exception ( @result )
220+ end
221+
222+ it 'should raise ReferenceValidationError' do
223+ expect ( @result . exception ) . to be_a_kind_of ( OctocatalogDiff ::Catalog ::ReferenceValidationError )
224+ end
225+
226+ it 'should have formatted error messages' do
227+ msg = @result . exception . message
228+ expect ( msg ) . to match ( /exec\[ before alias caller\] -> before\[ Exec\[ before alias target\] \] / )
229+ expect ( msg ) . to match ( /exec\[ notify alias caller\] -> before\[ Exec\[ notify alias target\] \] / )
230+ expect ( msg ) . to match ( /exec\[ require alias caller\] -> before\[ Exec\[ require alias target\] \] / )
231+ expect ( msg ) . to match ( /exec\[ subscribe alias caller\] -> before\[ Exec\[ subscribe alias target\] \] / )
232+ end
233+ end
234+ end
235+
191236describe 'validation of references in catalog-diff' do
192237 context 'with valid catalog' do
193238 before ( :all ) do
0 commit comments