Merge pull request #588 from werekraken/modules2873
[puppet-modules/puppetlabs-apt.git] / spec / defines / ppa_spec.rb
index c110e50f43dfc5c4a54e725b702a7cc7dfad250a..5080a876bb86b13adb86840d6c9c96cbee38a3ca 100644 (file)
@@ -16,12 +16,12 @@ describe 'apt::ppa' do
       }
     end
 
-    let(:title) { 'ppa:needs/such.substitution/wow' }
+    let(:title) { 'ppa:needs/such.substitution/wow+type' }
     it { is_expected.to_not contain_package('python-software-properties') }
-    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with({
       :environment => [],
-      :command     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
-      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
+      :command     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow_type-natty.list',
       :user        => 'root',
       :logoutput   => 'on_failure',
     })
@@ -57,7 +57,7 @@ describe 'apt::ppa' do
 
     let(:title) { 'ppa:needs/such.substitution/wow' }
     it { is_expected.to contain_package('software-properties-common') }
-    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({
       'environment' => [],
       'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
       'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
@@ -72,6 +72,46 @@ describe 'apt::ppa' do
     }
   end
 
+  describe 'package_manage => true, multiple ppas, MODULES-2873' do
+    let :pre_condition do
+      'class { "apt": }
+       apt::ppa {"ppa:foo":
+         package_manage => true
+       }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '11.04',
+        :lsbdistcodename => 'natty',
+        :operatingsystem => 'Ubuntu',
+        :osfamily        => 'Debian',
+        :lsbdistid       => 'Ubuntu',
+        :puppetversion   => Puppet.version,
+      }
+    end
+    let :params do
+      {
+        :package_manage => true,
+      }
+    end
+
+    let(:title) { 'ppa:bar' }
+    it { is_expected.to contain_package('python-software-properties') }
+    it { is_expected.to contain_exec('add-apt-repository-ppa:bar').that_notifies('Class[Apt::Update]').with({
+      'environment' => [],
+      'command'     => '/usr/bin/add-apt-repository -y ppa:bar',
+      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/bar-natty.list',
+      'user'        => 'root',
+      'logoutput'   => 'on_failure',
+    })
+    }
+
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/bar-natty.list').that_requires('Exec[add-apt-repository-ppa:bar]').with({
+      'ensure' => 'file',
+    })
+    }
+  end
+
   describe 'package_manage => false' do
     let :pre_condition do
       'class { "apt": }'
@@ -94,7 +134,7 @@ describe 'apt::ppa' do
 
     let(:title) { 'ppa:needs/such.substitution/wow' }
     it { is_expected.to_not contain_package('python-software-properties') }
-    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({
       'environment' => [],
       'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
       'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
@@ -135,7 +175,7 @@ describe 'apt::ppa' do
     let(:title) { 'ppa:foo' }
     it { is_expected.to compile.with_all_deps }
     it { is_expected.to contain_package('software-properties-common') }
-    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
       :environment => [],
       :command     => '/usr/bin/add-apt-repository  ppa:foo',
       :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
@@ -169,7 +209,7 @@ describe 'apt::ppa' do
     end
     let(:title) { 'ppa:foo' }
     it { is_expected.to contain_package('software-properties-common') }
-    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
       :environment => ['http_proxy=http://localhost:8080'],
       :command     => '/usr/bin/add-apt-repository  ppa:foo',
       :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
@@ -203,7 +243,7 @@ describe 'apt::ppa' do
     end
     let(:title) { 'ppa:foo' }
     it { is_expected.to contain_package('software-properties-common') }
-    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
       :environment => ['http_proxy=http://localhost:8180'],
       :command     => '/usr/bin/add-apt-repository  ppa:foo',
       :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
@@ -237,7 +277,7 @@ describe 'apt::ppa' do
     end
     let(:title) { 'ppa:foo' }
     it { is_expected.to contain_package('software-properties-common') }
-    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
       :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'],
       :command     => '/usr/bin/add-apt-repository  ppa:foo',
       :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
@@ -267,7 +307,7 @@ describe 'apt::ppa' do
         :ensure => 'absent'
       }
     end
-    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
+    it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Class[Apt::Update]').with({
       :ensure => 'absent',
     })
     }