Skip to content

Commit

Permalink
Merge pull request #1355 from bastelfreak/facter
Browse files Browse the repository at this point in the history
Mock facter version based on puppet version & unit tests: print puppet/facter version
  • Loading branch information
bastelfreak committed Nov 1, 2019
2 parents 93dadc0 + 4b0e3ef commit 1fca6e4
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_geo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx::resource::geo' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe 'nginx::resource::location' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_mailhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx::resource::mailhost' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx::resource::map' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx::resource::server' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_snippet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx::resource::snippet' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx::resource::streamhost' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/resource_upstream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'nginx::resource::upstream' do
on_supported_os.each do |os, facts|
context "on #{os}" do
context "on #{os} with Facter #{facts[:facterversion]} and Puppet #{facts[:puppetversion]}" do
let(:facts) do
facts
end
Expand Down
12 changes: 12 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
end

RSpec.configure do |c|
# getting the correct facter version is tricky. We use facterdb as a source to mock facts
# see https://github.com/camptocamp/facterdb
# people might provide a specific facter version. In that case we use it.
# Otherwise we need to match the correct facter version to the used puppet version.
# as of 2019-10-31, puppet 5 ships facter 3.11 and puppet 6 ships facter 3.14
# https://puppet.com/docs/puppet/5.5/about_agent.html
c.default_facter_version = if ENV['FACTERDB_FACTS_VERSION']
ENV['FACTERDB_FACTS_VERSION']
else
Gem::Dependency.new('', ENV['PUPPET_VERSION']).match?('', '5') ? '3.11.0' : '3.14.0'
end

# Coverage generation
c.after(:suite) do
RSpec::Puppet::Coverage.report!
Expand Down

0 comments on commit 1fca6e4

Please sign in to comment.