|
74 | 74 | @provider.load_current_resource |
75 | 75 | @provider.current_resource.version.should be_nil |
76 | 76 | end |
| 77 | + |
| 78 | + it "should throw an exception if a category isn't specified and multiple packages are found" do |
| 79 | + ::Dir.stub!(:[]).with("/var/db/pkg/*/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0", "/var/db/pkg/funny-words/git-1.0.0"]) |
| 80 | + @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) |
| 81 | + lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package) |
| 82 | + end |
77 | 83 | end |
78 | 84 |
|
79 | 85 | describe "once the state of the package is known" do |
80 | 86 |
|
81 | 87 | describe Chef::Provider::Package::Portage, "candidate_version" do |
82 | | - it "should return the candidate_version variable if already setup" do |
| 88 | + it "should return the candidate_version variable if already set" do |
83 | 89 | @provider.candidate_version = "1.0.0" |
84 | 90 | @provider.should_not_receive(:popen4) |
85 | 91 | @provider.candidate_version |
86 | 92 | end |
87 | 93 |
|
88 | | - it "should lookup the candidate_version if the variable is not already set" do |
89 | | - @status = mock("Status", :exitstatus => 0) |
| 94 | + it "should throw an exception if the exitstatus is not 0" do |
| 95 | + @status = mock("Status", :exitstatus => 1) |
90 | 96 | @provider.stub!(:popen4).and_return(@status) |
91 | | - @provider.should_receive(:popen4) |
92 | | - @provider.candidate_version |
| 97 | + lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package) |
93 | 98 | end |
94 | 99 |
|
95 | | - it "should throw and exception if the exitstatus is not 0" do |
96 | | - @status = mock("Status", :exitstatus => 1) |
97 | | - @provider.stub!(:popen4).and_return(@status) |
| 100 | + it "should find the candidate_version if a category is specifed and there are no duplicates" do |
| 101 | + output = <<EOF |
| 102 | +Searching... |
| 103 | +[ Results for search key : git ] |
| 104 | +[ Applications found : 14 ] |
| 105 | +
|
| 106 | +* app-misc/digitemp [ Masked ] |
| 107 | + Latest version available: 3.5.0 |
| 108 | + Latest version installed: [ Not Installed ] |
| 109 | + Size of files: 261 kB |
| 110 | + Homepage: http://www.digitemp.com/ http://www.ibutton.com/ |
| 111 | + Description: Temperature logging and reporting using Dallas Semiconductor's iButtons and 1-Wire protocol |
| 112 | + License: GPL-2 |
| 113 | +
|
| 114 | +* dev-util/git |
| 115 | + Latest version available: 1.6.0.6 |
| 116 | + Latest version installed: ignore |
| 117 | + Size of files: 2,725 kB |
| 118 | + Homepage: http://git.or.cz/ |
| 119 | + Description: GIT - the stupid content tracker, the revision control system heavily used by the Linux kernel team |
| 120 | + License: GPL-2 |
| 121 | +
|
| 122 | +* dev-util/gitosis [ Masked ] |
| 123 | + Latest version available: 0.2_p20080825 |
| 124 | + Latest version installed: [ Not Installed ] |
| 125 | + Size of files: 31 kB |
| 126 | + Homepage: http://eagain.net/gitweb/?p=gitosis.git;a=summary |
| 127 | + Description: gitosis -- software for hosting git repositories |
| 128 | + License: GPL-2 |
| 129 | +EOF |
| 130 | + |
| 131 | + @status = mock("Status", :exitstatus => 0) |
| 132 | + @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status) |
| 133 | + @provider.candidate_version.should == "1.6.0.6" |
| 134 | + end |
| 135 | + |
| 136 | + it "should find the candidate_version if a category is not specifed and there are no duplicates" do |
| 137 | + output = <<EOF |
| 138 | +Searching... |
| 139 | +[ Results for search key : git ] |
| 140 | +[ Applications found : 14 ] |
| 141 | +
|
| 142 | +* app-misc/digitemp [ Masked ] |
| 143 | + Latest version available: 3.5.0 |
| 144 | + Latest version installed: [ Not Installed ] |
| 145 | + Size of files: 261 kB |
| 146 | + Homepage: http://www.digitemp.com/ http://www.ibutton.com/ |
| 147 | + Description: Temperature logging and reporting using Dallas Semiconductor's iButtons and 1-Wire protocol |
| 148 | + License: GPL-2 |
| 149 | +
|
| 150 | +* dev-util/git |
| 151 | + Latest version available: 1.6.0.6 |
| 152 | + Latest version installed: ignore |
| 153 | + Size of files: 2,725 kB |
| 154 | + Homepage: http://git.or.cz/ |
| 155 | + Description: GIT - the stupid content tracker, the revision control system heavily used by the Linux kernel team |
| 156 | + License: GPL-2 |
| 157 | +
|
| 158 | +* dev-util/gitosis [ Masked ] |
| 159 | + Latest version available: 0.2_p20080825 |
| 160 | + Latest version installed: [ Not Installed ] |
| 161 | + Size of files: 31 kB |
| 162 | + Homepage: http://eagain.net/gitweb/?p=gitosis.git;a=summary |
| 163 | + Description: gitosis -- software for hosting git repositories |
| 164 | + License: GPL-2 |
| 165 | +EOF |
| 166 | + |
| 167 | + @status = mock("Status", :exitstatus => 0) |
| 168 | + @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) |
| 169 | + @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status) |
| 170 | + @provider.candidate_version.should == "1.6.0.6" |
| 171 | + end |
| 172 | + |
| 173 | + it "should throw an exception if a category is not specified and there are duplicates" do |
| 174 | + output = <<EOF |
| 175 | +Searching... |
| 176 | +[ Results for search key : git ] |
| 177 | +[ Applications found : 14 ] |
| 178 | +
|
| 179 | +* app-misc/digitemp [ Masked ] |
| 180 | + Latest version available: 3.5.0 |
| 181 | + Latest version installed: [ Not Installed ] |
| 182 | + Size of files: 261 kB |
| 183 | + Homepage: http://www.digitemp.com/ http://www.ibutton.com/ |
| 184 | + Description: Temperature logging and reporting using Dallas Semiconductor's iButtons and 1-Wire protocol |
| 185 | + License: GPL-2 |
| 186 | +
|
| 187 | +* app-misc/git |
| 188 | + Latest version available: 4.3.20 |
| 189 | + Latest version installed: [ Not Installed ] |
| 190 | + Size of files: 416 kB |
| 191 | + Homepage: http://www.gnu.org/software/git/ |
| 192 | + Description: GNU Interactive Tools - increase speed and efficiency of most daily task |
| 193 | + License: GPL-2 |
| 194 | +
|
| 195 | +* dev-util/git |
| 196 | + Latest version available: 1.6.0.6 |
| 197 | + Latest version installed: ignore |
| 198 | + Size of files: 2,725 kB |
| 199 | + Homepage: http://git.or.cz/ |
| 200 | + Description: GIT - the stupid content tracker, the revision control system heavily used by the Linux kernel team |
| 201 | + License: GPL-2 |
| 202 | +
|
| 203 | +* dev-util/gitosis [ Masked ] |
| 204 | + Latest version available: 0.2_p20080825 |
| 205 | + Latest version installed: [ Not Installed ] |
| 206 | + Size of files: 31 kB |
| 207 | + Homepage: http://eagain.net/gitweb/?p=gitosis.git;a=summary |
| 208 | + Description: gitosis -- software for hosting git repositories |
| 209 | + License: GPL-2 |
| 210 | +EOF |
| 211 | + |
| 212 | + @status = mock("Status", :exitstatus => 0) |
| 213 | + @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) |
| 214 | + @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status) |
98 | 215 | lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package) |
99 | 216 | end |
100 | 217 |
|
|
0 commit comments