Sha256: c8ce781f63e542e5598497197a263576ac6b05440c08671466dad0844f9dbd12

Contents?: true

Size: 1.54 KB

Versions: 43

Compression:

Stored size: 1.54 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

describe Puppet::Type.type(:package).provider(:aptrpm) do
  let :type do Puppet::Type.type(:package) end
  let :pkg do
    type.new(:name => 'faff', :provider => :aptrpm, :source => '/tmp/faff.rpm')
  end

  it { should be_versionable }

  context "when retrieving ensure" do
    before(:each) do
      Puppet::Util.stubs(:which).with("rpm").returns("/bin/rpm")
      pkg.provider.stubs(:which).with("rpm").returns("/bin/rpm")
      Puppet::Util::Execution.expects(:execute).with(["/bin/rpm", "--version"], {:combine => true, :custom_environment => {}, :failonfail => true}).returns("4.10.1\n").at_most_once
    end

    def rpm_args
      ['-q', 'faff', '--nosignature', '--nodigest', '--qf', "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\\n"]
    end

    def rpm(args = rpm_args)
      pkg.provider.expects(:rpm).with(*args)
    end

    it "should report absent packages" do
      rpm.raises(Puppet::ExecutionFailure, "couldn't find rpm")
      pkg.property(:ensure).retrieve.should == :absent
    end

    it "should report present packages correctly" do
      rpm.returns("faff-1.2.3-1 0 1.2.3-1 5 i686\n")
      pkg.property(:ensure).retrieve.should == "1.2.3-1-5"
    end
  end

  it "should try and install when asked" do
    pkg.provider.expects(:aptget). with('-q', '-y', 'install', 'faff'). returns(0)
    pkg.provider.install
  end

  it "should try and purge when asked" do
    pkg.provider.expects(:aptget).with('-y', '-q', 'remove', '--purge', 'faff').returns(0)
    pkg.provider.purge
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.6 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.5 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.4 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.3 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.2 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.1 spec/unit/provider/package/aptrpm_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/provider/package/aptrpm_spec.rb