Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mocked facts in tests #873

Merged
merged 1 commit into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :test do
gem 'voxpupuli-test', '~> 2.1', :require => false
gem 'voxpupuli-test', '~> 2.2', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
end
Expand Down
2 changes: 0 additions & 2 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
describe 'rabbitmq' do
on_supported_os.each do |os, facts|
context "on #{os}" do
systemd_facts = os_specific_facts(facts)
facts = facts.merge(systemd_facts)
let :facts do
facts
end
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

require 'voxpupuli/test/spec_helper'

add_mocked_facts!

if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
if facts
Expand Down
25 changes: 0 additions & 25 deletions spec/spec_helper_local.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,2 @@
add_custom_fact :rabbitmq_version, '3.6.1' # puppet-rabbitmq
add_custom_fact :erl_ssl_path, '/usr/lib64/erlang/lib/ssl-7.3.3.1/ebin' # puppet-rabbitmq

def os_specific_facts(facts)
case facts[:os]['family']
when 'Archlinux'
{ service_provider: 'systemd', systemd: true }
when 'Debian'
case facts[:os]['release']['major']
when '7'
{ service_provider: 'sysv', systemd: false }
when '14.04'
{ service_provider: 'upstart', systemd: false }
else
{ service_provider: 'systemd', systemd: true }
end
when 'RedHat'
case facts[:os]['release']['major']
when '6'
{ service_provider: 'sysv', systemd: false }
else
{ service_provider: 'systemd', systemd: true }
end
else
{ service_provider: 'systemd', systemd: true }
end
end