~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to spec/unit/provider/package/yum_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env rspec
 
2
require 'spec_helper'
 
3
 
 
4
provider = Puppet::Type.type(:package).provider(:yum)
 
5
 
 
6
describe provider do
 
7
  before do
 
8
    # Create a mock resource
 
9
     @resource = stub 'resource'
 
10
     @resource.stubs(:[]).with(:name).returns 'mypackage'
 
11
     @provider = provider.new(@resource)
 
12
     @provider.stubs(:resource).returns @resource
 
13
     @provider.stubs(:yum).returns 'yum'
 
14
     @provider.stubs(:rpm).returns 'rpm'
 
15
     @provider.stubs(:get).with(:name).returns 'mypackage'
 
16
     @provider.stubs(:get).with(:version).returns '1'
 
17
     @provider.stubs(:get).with(:release).returns '1'
 
18
     @provider.stubs(:get).with(:arch).returns 'i386'
 
19
  end
 
20
  # provider should repond to the following methods
 
21
   [:install, :latest, :update, :purge].each do |method|
 
22
     it "should have a(n) #{method}" do
 
23
       @provider.should respond_to(method)
 
24
    end
 
25
  end
 
26
 
 
27
  describe 'when installing' do
 
28
    it 'should call yum install for :installed' do
 
29
      @resource.stubs(:should).with(:ensure).returns :installed
 
30
      @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage')
 
31
      @provider.install
 
32
    end
 
33
    it 'should use :install to update' do
 
34
      @provider.expects(:install)
 
35
      @provider.update
 
36
    end
 
37
    it 'should be able to set version' do
 
38
      @resource.stubs(:should).with(:ensure).returns '1.2'
 
39
      @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage-1.2')
 
40
      @provider.stubs(:query).returns :ensure => '1.2'
 
41
      @provider.install
 
42
    end
 
43
    it 'should be able to downgrade' do
 
44
      @resource.stubs(:should).with(:ensure).returns '1.0'
 
45
      @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :downgrade, 'mypackage-1.0')
 
46
      @provider.stubs(:query).returns(:ensure => '1.2').then.returns(:ensure => '1.0')
 
47
      @provider.install
 
48
    end
 
49
  end
 
50
 
 
51
  describe 'when uninstalling' do
 
52
    it 'should use erase to purge' do
 
53
      @provider.expects(:yum).with('-y', :erase, 'mypackage')
 
54
      @provider.purge
 
55
    end
 
56
    it 'should use rpm to uninstall' do
 
57
      @provider.expects(:rpm).with('-e', 'mypackage-1-1.i386')
 
58
      @provider.uninstall
 
59
    end
 
60
  end
 
61
 
 
62
  it 'should be versionable' do
 
63
    provider.should be_versionable
 
64
  end
 
65
end
 
66