From 2928ffc921af0ec26ccfda1b973f7eebbc64d88f Mon Sep 17 00:00:00 2001 From: blsaws Date: Wed, 11 May 2016 21:22:03 -0700 Subject: Add baseline puppet module JIRA: COPPER-2 Change-Id: Ieb773594917aeca48ceca4250de9b4aede9961a8 Signed-off-by: blsaws --- .../provider/congress_config/ini_setting_spec.rb | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 components/congress/puppet/spec/unit/provider/congress_config/ini_setting_spec.rb (limited to 'components/congress/puppet/spec/unit/provider/congress_config/ini_setting_spec.rb') diff --git a/components/congress/puppet/spec/unit/provider/congress_config/ini_setting_spec.rb b/components/congress/puppet/spec/unit/provider/congress_config/ini_setting_spec.rb new file mode 100644 index 0000000..0c4b9fa --- /dev/null +++ b/components/congress/puppet/spec/unit/provider/congress_config/ini_setting_spec.rb @@ -0,0 +1,68 @@ +# +# these tests are a little concerning b/c they are hacking around the +# modulepath, so these tests will not catch issues that may eventually arise +# related to loading these plugins. +# I could not, for the life of me, figure out how to programatcally set the modulepath +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'inifile', + 'lib') +) +$LOAD_PATH.push( + File.join( + File.dirname(__FILE__), + '..', + '..', + '..', + 'fixtures', + 'modules', + 'openstacklib', + 'lib') +) +require 'spec_helper' +provider_class = Puppet::Type.type(:congress_config).provider(:ini_setting) +describe provider_class do + + it 'should default to the default setting when no other one is specified' do + resource = Puppet::Type::congress_config.new( + {:name => 'DEFAULT/foo', :value => 'bar'} + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('DEFAULT') + expect(provider.setting).to eq('foo') + end + + it 'should allow setting to be set explicitly' do + resource = Puppet::Type::congress_config.new( + {:name => 'dude/foo', :value => 'bar'} + ) + provider = provider_class.new(resource) + expect(provider.section).to eq('dude') + expect(provider.setting).to eq('foo') + end + + it 'should ensure absent when is specified as a value' do + resource = Puppet::Type::congress_config.new( + {:name => 'dude/foo', :value => ''} + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + + it 'should ensure absent when value matches ensure_absent_val' do + resource = Puppet::Type::congress_config.new( + {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' } + ) + provider = provider_class.new(resource) + provider.exists? + expect(resource[:ensure]).to eq :absent + end + +end -- cgit 1.2.3-korg