Facter.add('apt_package_updates') do
confine apt_has_updates: true
setcode do
- if Facter.version < '2.0.0'
- apt_package_updates[0].join(',')
- else
- apt_package_updates[0]
- end
+ apt_package_updates[0]
end
end
Facter.add('apt_package_dist_updates') do
confine apt_has_dist_updates: true
setcode do
- if Facter.version < '2.0.0'
- apt_dist_updates[0].join(',')
- else
- apt_dist_updates[0]
- end
+ apt_dist_updates[0]
end
end
Facter.add('apt_package_security_updates') do
confine apt_has_updates: true
setcode do
- if Facter.version < '2.0.0'
- apt_package_updates[1].join(',')
- else
- apt_package_updates[1]
- end
+ apt_package_updates[1]
end
end
Facter.add('apt_package_security_dist_updates') do
confine apt_has_dist_updates: true
setcode do
- if Facter.version < '2.0.0'
- apt_dist_updates[1].join(',')
- else
- apt_dist_updates[1]
- end
+ apt_dist_updates[1]
end
end
require 'net/ftp'
require 'tempfile'
-if RUBY_VERSION == '1.8.7'
- # Mothers cry, puppies die and Ruby 1.8.7's open-uri needs to be
- # monkeypatched to support passing in :ftp_passive_mode.
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..',
- 'puppet_x', 'apt_key', 'patch_openuri.rb'))
- OpenURI::Options[:ftp_active_mode] = false
-end
-
Puppet::Type.type(:apt_key).provide(:apt_key) do
desc 'apt-key provider for apt_key resource'
mk_resource_methods
- # Needed until PUP-1470 is fixed and we can drop support for Puppet versions
- # before that.
- def expired
- @property_hash[:expired]
- end
-
# Alias the setters of read-only properties
# to the read_only function.
alias_method :created=, :read_only
install_language_on(host, 'ja_JP.utf-8') if not_controller(host)
# This will be removed, this is temporary to test localisation.
end
- # Required for binding tests.
- if fact('osfamily') == 'RedHat'
- if fact('operatingsystemmajrelease') =~ %r{7} || fact('operatingsystem') =~ %r{Fedora}
- shell('yum install -y bzip2')
- end
- end
on host, puppet('module', 'install', 'stahnma/epel')
end
end
--- /dev/null
+if ENV['COVERAGE'] == 'yes'
+ require 'simplecov'
+ require 'simplecov-console'
+ require 'codecov'
+
+ SimpleCov.formatters = [
+ SimpleCov::Formatter::HTMLFormatter,
+ SimpleCov::Formatter::Console,
+ SimpleCov::Formatter::Codecov,
+ ]
+ SimpleCov.start do
+ track_files 'lib/**/*.rb'
+
+ add_filter '/spec'
+
+ # do not track vendored files
+ add_filter '/vendor'
+ add_filter '/.vendor'
+
+ # do not track gitignored files
+ # this adds about 4 seconds to the coverage check
+ # this could definitely be optimized
+ add_filter do |f|
+ # system returns true if exit status is 0, which with git-check-ignore means file is ignored
+ system("git check-ignore --quiet #{f.filename}")
+ end
+ end
+end
"Conf planet.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"
Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').returns apt_output
end
- if Facter.version < '2.0.0'
- it { is_expected.to eq('extremetuxracer,planet.rb') }
- else
- it { is_expected.to eq(['extremetuxracer', 'planet.rb']) }
- end
+ it { is_expected.to eq(['extremetuxracer', 'planet.rb']) }
end
end
"Conf curl (7.52.1-5+deb9u2 Debian-Security:9/stable [amd64])\n" \
end
- if Facter.version < '2.0.0'
- it { is_expected.to eq('curl') }
- else
- it { is_expected.to eq(['curl']) }
- end
+ it { is_expected.to eq(['curl']) }
end
describe 'on Ubuntu' do
"Conf procps (2:3.3.10-4ubuntu2.3 Ubuntu:16.04/xenial-updates [amd64])\n"
end
- if Facter.version < '2.0.0'
- it { is_expected.to eq('tzdata,curl') }
- else
- it { is_expected.to eq(['tzdata', 'curl']) }
- end
+ it { is_expected.to eq(['tzdata', 'curl']) }
end
end
end
"Conf unhide.rb (22-2~bpo8+1 Debian Backports:jessie-backports [all])\n"
Facter::Util::Resolution.expects(:exec).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').returns apt_output
end
- if Facter.version < '2.0.0'
- it { is_expected.to eq('tzdata,unhide.rb') }
- else
- it { is_expected.to eq(['tzdata', 'unhide.rb']) }
- end
+ it { is_expected.to eq(['tzdata', 'unhide.rb']) }
end
end