|
29 | 29 | :updated => nil, |
30 | 30 | :source => "/tmp/wget_1.11.4-1ubuntu1_amd64.deb" |
31 | 31 | ) |
32 | | - @current_resource = mock("Chef::Resource::Package", |
33 | | - :null_object => true, |
34 | | - :name => "wget", |
35 | | - :version => nil, |
36 | | - :package_name => nil, |
37 | | - :updated => nil |
38 | | - ) |
39 | 32 |
|
40 | 33 | @provider = Chef::Provider::Package::Dpkg.new(@node, @new_resource) |
41 | | - Chef::Resource::Package.stub!(:new).and_return(@current_resource) |
42 | 34 |
|
43 | 35 | @stdin = mock("STDIN", :null_object => true) |
44 | 36 | @stdout = mock("STDOUT", :null_object => true) |
|
51 | 43 | end |
52 | 44 |
|
53 | 45 | it "should create a current resource with the name of the new_resource" do |
54 | | - Chef::Resource::Package.should_receive(:new).and_return(@current_resource) |
55 | 46 | @provider.load_current_resource |
| 47 | + @provider.current_resource.package_name.should == "wget" |
56 | 48 | end |
57 | 49 |
|
58 | | - it "should set the current resources package name to the new resources package name" do |
59 | | - @current_resource.should_receive(:package_name).with(@new_resource.package_name) |
60 | | - @provider.load_current_resource |
61 | | - end |
62 | | - |
63 | 50 | it "should raise an exception if a source is supplied but not found" do |
64 | 51 | ::File.stub!(:exists?).and_return(false) |
65 | 52 | lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package) |
|
68 | 55 | it "should get the source package version from dpkg-deb if provided" do |
69 | 56 | @stdout.stub!(:each).and_yield("wget\t1.11.4-1ubuntu1") |
70 | 57 | @provider.stub!(:popen4).with("dpkg-deb -W #{@new_resource.source}").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
71 | | - @current_resource.should_receive(:package_name).with("wget") |
72 | 58 | @new_resource.should_receive(:version).with("1.11.4-1ubuntu1") |
73 | 59 | @provider.load_current_resource |
| 60 | + @provider.current_resource.package_name.should == "wget" |
| 61 | + end |
| 62 | + |
| 63 | + it "gets the source package name from dpkg-deb correctly when the package name has `-' or `+' characters" do |
| 64 | + @stdout.stub!(:each).and_yield("foo-pkg++2\t1.11.4-1ubuntu1") |
| 65 | + @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
| 66 | + @provider.load_current_resource |
| 67 | + @provider.current_resource.package_name.should == "foo-pkg++2" |
74 | 68 | end |
75 | 69 |
|
76 | 70 | it "should raise an exception if the source is not set but we are installing" do |
|
99 | 93 | and_yield("Config-Version: 1.11.4-1ubuntu1"). |
100 | 94 | and_yield("Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5)"). |
101 | 95 | and_yield("Conflicts: wget-ssl") |
102 | | - @provider.stub!(:popen4).with("dpkg -s #{@current_resource.package_name}").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
103 | | - @current_resource.should_receive(:version).with("1.11.4-1ubuntu1") |
| 96 | + @provider.stub!(:popen4).with("dpkg -s wget").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) |
| 97 | + |
104 | 98 | @provider.load_current_resource |
| 99 | + @provider.current_resource.version.should == "1.11.4-1ubuntu1" |
105 | 100 | end |
106 | | - |
| 101 | + |
107 | 102 | it "should raise an exception if dpkg fails to run" do |
108 | 103 | @status = mock("Status", :exitstatus => -1) |
109 | 104 | @provider.stub!(:popen4).and_return(@status) |
|
0 commit comments