X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fclasses%2Fapt_spec.rb;h=0b677564d1d1cbc84193369f1e1c078e75be4b6d;hb=d946753dc4c2ac376e3d1edae92d6884516ebe3a;hp=080bc81760282c70a9bf7b5a45249f06a645bd5d;hpb=450fadb86a507fc8d268aec8ab872ab502db992c;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 080bc81..0b67756 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' describe 'apt', :type => :class do - let(:facts) { { :lsbdistid => 'Debian' } } + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let :default_params do { :disable_keys => :undef, @@ -19,6 +19,10 @@ describe 'apt', :type => :class do :purge_sources_list => true, :purge_sources_list_d => true, }, + { + :purge_preferences => true, + :purge_preferences_d => true, + }, { :disable_keys => false } @@ -86,6 +90,49 @@ describe 'apt', :type => :class do }) end } + it { + if param_hash[:purge_preferences] + should create_file('apt-preferences').with({ + :ensure => 'present', + :path => '/etc/apt/preferences', + :owner => 'root', + :group => 'root', + :mode => '0644', + :content => /Explanation/, + }) + else + should create_file('apt-preferences').with({ + :ensure => 'present', + :path => '/etc/apt/preferences', + :owner => 'root', + :group => 'root', + :mode => '0644', + :content => nil, + }) + end + } + + it { + if param_hash[:purge_preferences_d] + should create_file("preferences.d").with({ + 'path' => "/etc/apt/preferences.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => true, + 'recurse' => true, + }) + else + should create_file("preferences.d").with({ + 'path' => "/etc/apt/preferences.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => false, + 'recurse' => false, + }) + end + } it { should contain_exec("apt_update").with({ @@ -117,7 +164,7 @@ describe 'apt', :type => :class do if param_hash[:proxy_host] should contain_file('configure-apt-proxy').with( 'path' => '/etc/apt/apt.conf.d/proxy', - 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";", + 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n", 'notify' => "Exec[apt_update]" ) else