Add --no-validate-references to specify nothing to be validated

This commit is contained in:
Kevin Paulisse 2016-12-23 14:36:44 -05:00
Родитель 12e1e877a9
Коммит f650537b9d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 66DA91D838188671
3 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -9,14 +9,18 @@ OctocatalogDiff::CatalogDiff::Cli::Options::Option.newoption(:validate_reference
has_weight 205
def parse(parser, options)
parser.on('--validate-references "before,require,subscribe,notify"', Array, 'References to validate') do |res|
options[:validate_references] ||= []
res.each do |item|
unless %w(before require subscribe notify).include?(item)
raise ArgumentError, "Invalid reference validation #{item}"
end
parser.on('--[no-]validate-references "before,require,subscribe,notify"', Array, 'References to validate') do |res|
if res == false
options[:validate_references] = []
else
options[:validate_references] ||= []
res.each do |item|
unless %w(before require subscribe notify).include?(item)
raise ArgumentError, "Invalid reference validation #{item}"
end
options[:validate_references] << item
options[:validate_references] << item
end
end
end
end

Просмотреть файл

@ -35,7 +35,7 @@ end
describe 'validation specifically disabled' do
before(:all) do
argv = ['--catalog-only', '-n', 'rspec-node.github.net', '--no-reference-validation']
argv = ['--catalog-only', '-n', 'rspec-node.github.net', '--no-validate-references']
@result = OctocatalogDiff::Integration.integration(
hiera_config: 'hiera.yaml',
spec_fact_file: 'facts.yaml',
@ -45,7 +45,7 @@ describe 'validation specifically disabled' do
end
it 'should return the valid catalog' do
expect(@result.exitcode).to eq(2)
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
end
end

Просмотреть файл

@ -19,6 +19,11 @@ describe OctocatalogDiff::CatalogDiff::Cli::Options do
expect(result[:validate_references]).to eq(%w(before require notify subscribe))
end
it 'should accept negative' do
result = run_optparse(['--no-validate-references'])
expect(result[:validate_references]).to eq([])
end
it 'should fail for an invalid argument' do
expect { run_optparse(['--validate-references', 'chicken']) }.to raise_error(ArgumentError, /Invalid reference validation/)
end