puppet-openstack_extras/spec/functions/validate_yum_hash_spec.rb
Tobias Urdin 79481df8ef Use puppet4 functions-api
Depends-On: https://review.openstack.org/#/c/614782/
Change-Id: I7bb50c4e591585b80661fe0d41c7cc2dfec5fdf8
2018-11-01 16:31:22 +01:00

32 lines
1011 B
Ruby

require 'spec_helper'
describe 'validate_yum_hash' do
it 'exists' do
is_expected.not_to eq(nil)
end
it 'throws error with more than one argument' do
is_expected.to run.with_params({'title' => {'key1' => 'value1'}, 'title2' => {'key2' => 'value2'}}).and_raise_error(Puppet::Error)
end
it 'fails with no arguments' do
is_expected.to run.with_params.and_raise_error(Puppet::Error)
end
it 'fails with invalid hash' do
is_expected.to run.with_params({'title' => {'invalid' => 'val'}}).and_raise_error(Puppet::Error)
end
it 'fails with invalid hash with multiple entries' do
is_expected.to run.with_params({'title' => {'baseurl' => 'placeholder', 'invalid' => 'val'}}).and_raise_error(Puppet::Error)
end
it 'works with valid entry' do
is_expected.to run.with_params({'title' => {'baseurl' => 'placeholder'}})
end
it 'works with multiple valid entries' do
is_expected.to run.with_params({'title' => {'baseurl' => 'placeholder', 'timeout' => 30}})
end
end