[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Matt Robinson matt at puppetlabs.com
Tue May 10 08:02:21 UTC 2011


The following commit has been merged in the experimental branch:
commit 04389f502787c6569ffcfa89eb63d76c3c63d29c
Author: Dan Bode <bodepd at gmail.com>
Date:   Tue Sep 7 17:46:39 2010 -0400

    (#4711) Provide unit tests for yum package provider.

diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
new file mode 100644
index 0000000..09c81f7
--- /dev/null
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider = Puppet::Type.type(:package).provider(:yum)
+
+describe provider do
+  before do
+    # Create a mock resource
+     @resource = stub 'resource'
+     @resource.stubs(:[]).with(:name).returns 'mypackage'
+     @provider = provider.new(@resource)
+     @provider.stubs(:resource).returns @resource
+     @provider.stubs(:yum).returns 'yum'
+     @provider.stubs(:rpm).returns 'rpm'
+     @provider.stubs(:get).with(:name).returns 'mypackage'
+     @provider.stubs(:get).with(:version).returns '1'
+     @provider.stubs(:get).with(:release).returns '1'
+     @provider.stubs(:get).with(:arch).returns 'i386'
+  end
+  # provider should repond to the following methods
+   [:install, :latest, :update, :purge].each do |method|
+     it "should have a(n) #{method}" do
+       @provider.should respond_to(method)
+    end
+  end
+
+  describe 'when installing' do
+    it 'should call yum install for :installed' do
+      @resource.stubs(:should).with(:ensure).returns :installed
+      @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage')
+      @provider.install
+    end
+    it "should use :install to update" do
+      @provider.expects(:install)
+      @provider.update
+    end
+    it "should be able to set version" do
+      @resource.stubs(:should).with(:ensure).returns "1.2"
+      @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage-1.2')
+      @provider.stubs(:query).returns :ensure => '1.2' 
+      @provider.install
+    end
+  end
+
+  describe 'when uninstalling' do
+    it "should use erase to purge" do
+      @provider.expects(:yum).with("-y", :erase, 'mypackage')
+      @provider.purge
+    end
+    it 'should use rpm to uninstall' do
+      @provider.expects(:rpm).with('-e', 'mypackage-1-1.i386')
+      @provider.uninstall
+    end
+  end
+
+  it "should be versionable" do
+    provider.should be_versionable
+  end
+end
+

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list