blob: 40e497c27aaf85435c986ed2668b80e515c2e837 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
provider_class = Puppet::Type.type(:package).provider(:aix)
describe provider_class do
before(:each) do
# Create a mock resource
@resource = stub 'resource'
# A catch all; no parameters set
@resource.stubs(:[]).returns(nil)
# But set name and source
@resource.stubs(:[]).with(:name).returns "mypackage"
@resource.stubs(:[]).with(:source).returns "mysource"
@resource.stubs(:[]).with(:ensure).returns :installed
@provider = provider_class.new
@provider.resource = @resource
end
[:install, :uninstall, :latest, :query, :update].each do |method|
it "should have a #{method} method" do
@provider.should respond_to(method)
end
end
it "should uninstall a package" do
@provider.expects(:installp).with('-gu', 'mypackage')
@provider.uninstall
end
describe "when installing" do
it "should install a package" do
@resource.stubs(:should).with(:ensure).returns(:installed)
@provider.expects(:installp).with('-acgwXY', '-d', 'mysource', 'mypackage')
@provider.install
end
it "should install a specific package version" do
@resource.stubs(:should).with(:ensure).returns("1.2.3.4")
@provider.expects(:installp).with('-acgwXY', '-d', 'mysource', 'mypackage 1.2.3.4')
@provider.install
end
end
describe "when finding the latest version" do
it "should return the current version when no later version is present" do
@provider.stubs(:latest_info).returns(nil)
@provider.stubs(:properties).returns( { :ensure => "1.2.3.4" } )
@provider.latest.should == "1.2.3.4"
end
it "should return the latest version of a package" do
@provider.stubs(:latest_info).returns( { :version => "1.2.3.5" } )
@provider.latest.should == "1.2.3.5"
end
end
it "update should install a package" do
@provider.expects(:install).with(false)
@provider.update
end
end
|