Allow for disabling repository configuration
[integration/packaging/puppet-opendaylight.git] / spec / classes / opendaylight_repos_spec.rb
1 require 'spec_helper'
2
3 describe 'opendaylight::repos' do
4   shared_examples_for "opendaylight::repos on Debian" do
5     context "with defaults" do
6       it { should contain_class('opendaylight::repos') }
7       it { should contain_class('apt') }
8       it { should contain_apt__ppa('ppa:odl-team/boron') }
9     end
10
11     context "with custom deb_repo" do
12       let(:params) do
13         { :deb_repo => 'ppa:foo/testing' }
14       end
15
16       it { should contain_apt__ppa('ppa:foo/testing') }
17     end
18   end
19   shared_examples_for "opendaylight::repos on RedHat" do
20     context "with defaults" do
21       it { should contain_class('opendaylight::repos') }
22       it {
23         should contain_yumrepo('opendaylight-5-testing').with(
24           :baseurl  => 'http://cbs.centos.org/repos/nfv7-opendaylight-5-testing/$basearch/os/',
25           :enabled  => 1,
26           :gpgcheck => 0,
27         )
28       }
29     end
30
31     context "with custom rpm repo options" do
32       let(:params) do
33         {
34           :rpm_repo => 'testing',
35           :rpm_repo_enabled => 0,
36           :rpm_repo_gpgcheck => 1,
37         }
38       end
39       it {
40         should contain_yumrepo('testing').with(
41           :baseurl  => 'http://cbs.centos.org/repos/nfv7-testing/$basearch/os/',
42           :enabled  => 0,
43           :gpgcheck => 1,
44         )
45       }
46
47     end
48   end
49
50   describe "on unsupported os" do
51     context "when on Solaris" do
52       let(:facts) do
53         {:osfamily => 'Solaris', :operatingsystem => 'Solaris'}
54       end
55
56
57       it 'should fail' do
58         expect { is_expected.to raise_error(Puppet::Error) }
59       end
60     end
61   end
62
63   on_supported_os.each do |os, facts|
64     context "on #{os}" do
65       let (:facts) do
66         facts
67       end
68
69       it_behaves_like "opendaylight::repos on #{facts[:osfamily]}"
70     end
71   end
72
73 end