Cleaned up acceptance tests
[puppet-modules/puppetlabs-apt.git] / spec / classes / init_spec.rb
1 require 'spec_helper'
2 describe 'apt' do
3   context 'with sources defined on valid osfamily' do
4     let :facts do
5       { :osfamily        => 'Debian',
6         :lsbdistcodename => 'precise',
7         :lsbdistid       => 'Debian',
8       }
9     end
10     let(:params) { { :sources => {
11       'debian_unstable' => {
12         'location'          => 'http://debian.mirror.iweb.ca/debian/',
13         'release'           => 'unstable',
14         'repos'             => 'main contrib non-free',
15         'required_packages' => 'debian-keyring debian-archive-keyring',
16         'key'               => '55BE302B',
17         'key_server'        => 'subkeys.pgp.net',
18         'pin'               => '-10',
19         'include_src'       => true
20       },
21       'puppetlabs' => {
22         'location'   => 'http://apt.puppetlabs.com',
23         'repos'      => 'main',
24         'key'        => '4BD6EC30',
25         'key_server' => 'pgp.mit.edu',
26       }
27     } } }
28
29     it {
30       should contain_file('debian_unstable.list').with({
31         'ensure'  => 'present',
32         'path'    => '/etc/apt/sources.list.d/debian_unstable.list',
33         'owner'   => 'root',
34         'group'   => 'root',
35         'mode'    => '0644',
36         'notify'  => 'Exec[apt_update]',
37       })
38     }
39
40     it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
41     it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
42
43     it {
44       should contain_file('puppetlabs.list').with({
45         'ensure'  => 'present',
46         'path'    => '/etc/apt/sources.list.d/puppetlabs.list',
47         'owner'   => 'root',
48         'group'   => 'root',
49         'mode'    => '0644',
50         'notify'  => 'Exec[apt_update]',
51       })
52     }
53
54     it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
55     it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
56   end
57
58   context 'with unsupported osfamily' do
59     let :facts do
60       { :osfamily        => 'Darwin', }
61     end
62
63     it do
64       expect {
65        should compile
66       }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
67     end
68   end
69 end