Skip to content

Commit

Permalink
Merge 84a5157 into 3daaf69
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithWard committed Jul 30, 2020
2 parents 3daaf69 + 84a5157 commit 27f4c49
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 28 deletions.
1 change: 0 additions & 1 deletion .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
secure: "FAK3Izs5bSZyblGvcFnGWm0exZV5+v9pbwfRDD2oihWxX3U3pArGW+3XcwcJfLQgrUYBsOTmHC8yPjlgTBYeIt/5pvg9X+3jwNgeto6kozpI/nvAq4NtcHhzxRejuPELhFYeXZ3hEw0w+v/ZRo2cNLwI0LLpiWEDvCMZN1CJ2RY="
spec/spec_helper.rb:
spec_overrides: "require 'spec_helper_methods'"
mock_with: ':mocha'
spec/spec_helper_acceptance.rb:
unmanaged: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'voxpupuli-test', '>= 1.0.0', :require => false
gem 'voxpupuli-test', '~> 1.5', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
end
Expand Down
4 changes: 0 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
# https://github.com/voxpupuli/modulesync
# https://github.com/voxpupuli/modulesync_config

RSpec.configure do |c|
c.mock_with :mocha
end

# puppetlabs_spec_helper will set up coverage if the env variable is set.
# We want to do this if lib exists and it hasn't been explicitly set.
ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/collectd_real_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
after { Facter.clear }

it 'is 5.1.0 according to output' do
Facter::Util::Resolution.stubs(:which).with('collectd').returns('/usr/sbin/collectd')
allow(Facter::Util::Resolution).to receive(:which).with('collectd').and_return('/usr/sbin/collectd')
sample_collectd_help = File.read(fixtures('facts', 'collectd_help'))
Facter::Util::Resolution.stubs(:exec).with('collectd -h').returns(sample_collectd_help)
allow(Facter::Util::Resolution).to receive(:exec).with('collectd -h').and_return(sample_collectd_help)
expect(Facter.fact(:collectd_version).value).to eq('5.1.0')
end

it 'is 5.1.0.git according to output' do
Facter::Util::Resolution.stubs(:which).with('collectd').returns('/usr/sbin/collectd')
allow(Facter::Util::Resolution).to receive(:which).with('collectd').and_return('/usr/sbin/collectd')
sample_collectd_help_git = File.read(fixtures('facts', 'collectd_help_git'))
Facter::Util::Resolution.stubs(:exec).with('collectd -h').returns(sample_collectd_help_git)
allow(Facter::Util::Resolution).to receive(:exec).with('collectd -h').and_return(sample_collectd_help_git)
expect(Facter.fact(:collectd_version).value).to eq('5.1.0.git')
end

it 'is not defined if collectd not installed' do
Facter::Util::Resolution.stubs(:which).with('collectd').returns(nil)
allow(Facter::Util::Resolution).to receive(:which).with('collectd').and_return(nil)
expect(Facter.fact(:collectd_version).value).to be_nil
end
end
34 changes: 17 additions & 17 deletions spec/unit/python_dir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,44 @@
context 'default path' do
before do
# This is needed to make this spec work on Fedora, apparently
Facter.fact(:osfamily).stubs(:value).returns('AnythingNotRedHat')
Facter::Util::Resolution.stubs(:which).with('python').returns(true)
Facter::Util::Resolution.stubs(:exec).with('python -c "import site; print(site.getsitepackages()[0])"').returns('/usr/local/lib/python2.7/dist-packages')
allow(Facter).to receive(:value).with(:osfamily).and_return('AnythingNotRedHat')
allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('python -c "import site; print(site.getsitepackages()[0])"').and_return('/usr/local/lib/python2.7/dist-packages')
end
it do
expect(Facter.value(:python_dir)).to eq('/usr/local/lib/python2.7/dist-packages')
expect(Facter.fact(:python_dir).value).to eq('/usr/local/lib/python2.7/dist-packages')
end
end

context 'RedHat' do
before do
Facter.fact(:osfamily).stubs(:value).returns('RedHat')
Facter::Util::Resolution.stubs(:which).with('python').returns(true)
Facter::Util::Resolution.stubs(:exec).with('python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"').returns('/usr/lib/python2.7/site-packages')
allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat')
allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"').and_return('/usr/lib/python2.7/site-packages')
end
it do
expect(Facter.value(:python_dir)).to eq('/usr/lib/python2.7/site-packages')
expect(Facter.fact(:python_dir).value).to eq('/usr/lib/python2.7/site-packages')
end
end

context 'RedHat versioned python' do
before do
Facter.fact(:osfamily).stubs(:value).returns('RedHat')
Facter::Util::Resolution.stubs(:which).with('python').returns(false)
Facter::Util::Resolution.stubs(:which).with('python3').returns(true)
Facter::Util::Resolution.stubs(:exec).with('python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"').returns('/usr/lib/python3.6/site-packages')
allow(Facter).to receive(:value).with(:osfamily).and_return('RedHat')
allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(false)
allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"').and_return('/usr/lib/python3.6/site-packages')
end
it do
expect(Facter.value(:python_dir)).to eq('/usr/lib/python3.6/site-packages')
expect(Facter.fact(:python_dir).value).to eq('/usr/lib/python3.6/site-packages')
end
end
end

it 'is empty string if python not installed' do
Facter::Util::Resolution.stubs(:which).with('python').returns(nil)
Facter::Util::Resolution.stubs(:which).with('python2').returns(nil)
Facter::Util::Resolution.stubs(:which).with('python3').returns(nil)
File.stubs(:exist?).with('/usr/libexec/platform-python').returns(nil)
allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(nil)
allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(nil)
allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(nil)
allow(File).to receive(:exist?).with('/usr/libexec/platform-python').and_return(nil)
expect(Facter.fact(:python_dir).value).to eq('')
end
end

0 comments on commit 27f4c49

Please sign in to comment.