- it { should contain_apt__params }
-
- it { should contain_file("#{title}.list").with({
- 'ensure' => param_hash[:ensure],
- 'path' => filename,
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- 'content' => content,
- })
- }
-
- it {
- if param_hash[:pin]
- should contain_apt__pin(title).with({
- "priority" => param_hash[:pin],
- "before" => "File[#{title}.list]"
- })
- else
- should_not contain_apt__pin(title).with({
- "priority" => param_hash[:pin],
- "before" => "File[#{title}.list]"
- })
- end
- }
-
- it {
- should contain_exec("apt_update").with({
- "command" => "/usr/bin/apt-get update",
- "refreshonly" => true
- })
- }
-
- it {
- if param_hash[:required_packages]
- should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
- "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
- "subscribe" => "File[#{title}.list]",
- "refreshonly" => true,
- "before" => 'Exec[apt_update]',
- })
- else
- should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
- "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
- "subscribe" => "File[#{title}.list]",
- "refreshonly" => true
- })
- end
- }
-
- it {
- if param_hash[:key]
- should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
- "key" => param_hash[:key],
- "ensure" => :present,
- "key_server" => param_hash[:key_server],
- "key_content" => param_hash[:key_content],
- "key_source" => param_hash[:key_source],
- "before" => "File[#{title}.list]"
- })
- else
- should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
- "key" => param_hash[:key],
- "ensure" => :present,
- "key_server" => param_hash[:key_server],
- "key_content" => param_hash[:key_content],
- "key_source" => param_hash[:key_source],
- "before" => "File[#{title}.list]"
- })
- end
+ it { is_expected.to contain_apt__setting('list-my_source').with({
+ :ensure => 'present',
+ }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
+ }
+
+ it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
+ :ensure => 'present',
+ :priority => '10',
+ :origin => 'debian.mirror.iweb.ca',
+ })
+ }
+
+ it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
+ :ensure => 'present',
+ :id => GPG_KEY_ID,
+ })
+ }
+ end
+ end
+
+ context 'allow_unsigned true' do
+ let :facts do
+ {
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ :osfamily => 'Debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let :params do
+ {
+ :location => 'hello.there',
+ :allow_unsigned => true,
+ }
+ end
+
+ it { is_expected.to contain_apt__setting('list-my_source').with({
+ :ensure => 'present',
+ }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/)
+ }
+ end
+
+ context 'architecture equals x86_64' do
+ let :facts do
+ {
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ :osfamily => 'Debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let :params do
+ {
+ :location => 'hello.there',
+ :include => {'deb' => false, 'src' => true,},
+ :architecture => 'x86_64',
+ }
+ end
+
+ it { is_expected.to contain_apt__setting('list-my_source').with({
+ :ensure => 'present',
+ }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/)
+ }
+ end
+
+ context 'include_src => true' do
+ let :facts do
+ {
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ :osfamily => 'Debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let :params do
+ {
+ :location => 'hello.there',
+ :include_src => true,
+ }
+ end
+
+ it { is_expected.to contain_apt__setting('list-my_source').with({
+ :ensure => 'present',
+ }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
+ }
+ end
+
+ context 'include_deb => false' do
+ let :facts do
+ {
+ :lsbdistid => 'debian',
+ :lsbdistcodename => 'wheezy',
+ :osfamily => 'debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let :params do
+ {
+ :location => 'hello.there',
+ :include_deb => false,
+ }
+ end
+
+ it { is_expected.to contain_apt__setting('list-my_source').with({
+ :ensure => 'present',
+ }).without_content(/deb-src hello.there wheezy main\n/)
+ }
+ it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
+ end
+
+ context 'include_src => true and include_deb => false' do
+ let :facts do
+ {
+ :lsbdistid => 'debian',
+ :lsbdistcodename => 'wheezy',
+ :osfamily => 'debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let :params do
+ {
+ :location => 'hello.there',
+ :include_deb => false,
+ :include_src => true,
+ }
+ end
+
+ it { is_expected.to contain_apt__setting('list-my_source').with({
+ :ensure => 'present',
+ }).with_content(/deb-src hello.there wheezy main\n/)
+ }
+ it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
+ end
+
+ context 'include precedence' do
+ let :facts do
+ {
+ :lsbdistid => 'debian',
+ :lsbdistcodename => 'wheezy',
+ :osfamily => 'debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let :params do
+ {
+ :location => 'hello.there',
+ :include_deb => true,
+ :include_src => false,
+ :include => { 'deb' => false, 'src' => true },