From aeb3bdba1c66f245e9eda46a564a956252cc609b Mon Sep 17 00:00:00 2001 From: varac Date: Wed, 2 Nov 2016 21:26:14 +0100 Subject: Compile test, test apt::conf --- spec/defines/conf_spec.rb | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 spec/defines/conf_spec.rb (limited to 'spec/defines') diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb new file mode 100644 index 0000000..59f49df --- /dev/null +++ b/spec/defines/conf_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper' +describe 'apt::apt_conf', :type => :define do + let :pre_condition do + 'class { "apt": }' + end + let(:facts) { { + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :debian_release => 'jessie', + :lsbdistcodename => 'jessie', + :puppetversion => Puppet.version, } } + let :title do + 'norecommends' + end + + describe "when creating an apt_conf snippet" do + let :default_params do + { + :ensure => 'present', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + } + end + let :params do + default_params + end + let :filename do + "/etc/apt/apt.conf.d/norecommends" + end + + it { is_expected.to contain_file(filename).with({ + 'ensure' => 'present', + 'content' => /Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;/, + 'owner' => 'root', + # default to '0', not 'root' + #'group' => 'root', + 'mode' => '0644', + }) + } + + end + + describe "when creating a preference without content" do + let :params do + { + :ensure => 'absent', + } + end + + it 'fails' do + expect { subject.call } .to raise_error(Puppet::Error, /One of \$source or \$content must be specified for apt_conf norecommends/) + end + end + + describe "when removing an apt preference" do + let :params do + { + :ensure => 'absent', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + } + end + + let :filename do + "/etc/apt/apt.conf.d/norecommends" + end + + it { is_expected.to contain_file(filename).with({ + 'ensure' => 'absent', + }) + } + end +end -- cgit v1.2.3