Skip to content

Commit e0f6cee

Browse files
committed
Fix error messages and tests for catalog validators
1 parent 1d64186 commit e0f6cee

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

lib/octocatalog-diff/util/catalogs.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ def build_catalog(opts, logger = @logger)
231231
# @param catalog [OctocatalogDiff::Catalog] Catalog object
232232
# @param logger [Logger] Logger object (presently unused)
233233
# @param args [Hash] Additional arguments set specifically for validator
234-
# @return [Boolean] true if catalog is valid, false otherwise
235234
def catalog_validator(catalog = nil, _logger = @logger, args = {})
236235
return false unless catalog.is_a?(OctocatalogDiff::Catalog)
237236
catalog.validate_references if args[:task] == :to
238-
catalog.valid?
237+
return if catalog.valid?
238+
raise OctocatalogDiff::Errors::CatalogError, 'Catalog failed: Invalid catalog'
239239
end
240240
end
241241
end

lib/octocatalog-diff/util/parallel.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ def self.run_tasks_serial(result, task_array, logger)
152152
task_array.each_with_index do |ele, task_counter|
153153
result[task_counter] = execute_task(ele, logger)
154154
next if result[task_counter].status
155-
raise result[task_counter].exception
155+
raise result[task_counter].exception if result[task_counter].exception
156+
# :nocov:
157+
raise "Serial task #{task_counter} had status=#{result[task_counter].status} but no exception was set"
158+
# :nocov:
156159
end
157160
end
158161

@@ -171,12 +174,7 @@ def self.execute_task(task, logger)
171174
end
172175

173176
begin
174-
if task.validate(output, logger)
175-
logger.debug("Success #{task.description}")
176-
else
177-
logger.warn("Failed #{task.description}")
178-
result.status = false
179-
end
177+
task.validate(output, logger)
180178
rescue => exc
181179
logger.warn("Failed #{task.description}")
182180
result.status = false

spec/octocatalog-diff/tests/util/catalogs_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def valid?
198198
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
199199
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
200200
re = %r{ENC.*/asdkfjlfjkalksdfads wasn't found}
201-
expect { testobj.catalogs }.to raise_error(OctocatalogDiff::Errors::CatalogError, re)
201+
expect { testobj.catalogs }.to raise_error(Errno::ENOENT, re)
202202
end
203203
end
204204
end
@@ -211,7 +211,7 @@ def valid?
211211
logger, _logger_string = OctocatalogDiff::Spec.setup_logger
212212
testobj = OctocatalogDiff::Util::Catalogs.new(options, logger)
213213
re = %r{hiera.yaml.*/asdkfjlfjkalksdfads\) wasn't found}
214-
expect { testobj.catalogs }.to raise_error(OctocatalogDiff::Errors::CatalogError, re)
214+
expect { testobj.catalogs }.to raise_error(Errno::ENOENT, re)
215215
end
216216
end
217217
end

0 commit comments

Comments
 (0)