|
191 | 191 | expect(versions[version]).to eq(:rpm)
|
192 | 192 | end
|
193 | 193 | end
|
| 194 | + |
| 195 | + it "should be able to parse RPM package listings with letters in version" do |
| 196 | + showres_output = <<END |
| 197 | +cairo ALL @@R:cairo _all_filesets |
| 198 | + @@R:cairo-1.14.6-2waixX11 1.14.6-2waixX11 |
| 199 | +END |
| 200 | + packages = subject.send(:parse_showres_output, showres_output) |
| 201 | + expect(Set.new(packages.keys)).to eq(Set.new(['cairo'])) |
| 202 | + versions = packages['cairo'] |
| 203 | + expect(versions.has_key?('1.14.6-2waixX11')).to eq(true) |
| 204 | + expect(versions['1.14.6-2waixX11']).to eq(:rpm) |
| 205 | + end |
| 206 | + |
| 207 | + it "should raise error when parsing invalid RPM package listings" do |
| 208 | + showres_output = <<END |
| 209 | +cairo ALL @@R:cairo _all_filesets |
| 210 | + @@R:cairo-invalid_version invalid_version |
| 211 | +END |
| 212 | + expect{ subject.send(:parse_showres_output, showres_output) }.to raise_error(Puppet::Error, |
| 213 | + /Unable to parse output from nimclient showres: package string does not match expected rpm package string format/) |
| 214 | + end |
194 | 215 | end
|
195 | 216 |
|
196 | 217 | context "#determine_latest_version" do
|
|
220 | 241 | it "should return :installp for installp/bff packages" do
|
221 | 242 | expect(subject.send(:determine_package_type, bff_showres_output, 'mypackage.foo', '1.2.3.4')).to eq(:installp)
|
222 | 243 | end
|
| 244 | + |
| 245 | + it "should return :installp for security updates" do |
| 246 | + nimclient_showres_output = <<END |
| 247 | +bos.net ALL @@S:bos.net _all_filesets |
| 248 | + + 7.2.0.1 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.1 |
| 249 | + + 7.2.0.2 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.2 |
| 250 | +
|
| 251 | +END |
| 252 | + expect(subject.send(:determine_package_type, nimclient_showres_output, 'bos.net.tcp.ntp', '7.2.0.2')).to eq(:installp) |
| 253 | + end |
| 254 | + |
| 255 | + it "should raise error when invalid header format is given" do |
| 256 | + nimclient_showres_output = <<END |
| 257 | +bos.net ALL @@INVALID_TYPE:bos.net _all_filesets |
| 258 | + + 7.2.0.1 TCP/IP ntp Applications @@INVALID_TYPE:bos.net.tcp.ntp 7.2.0.1 |
| 259 | + + 7.2.0.2 TCP/IP ntp Applications @@INVALID_TYPE:bos.net.tcp.ntp 7.2.0.2 |
| 260 | +
|
| 261 | +END |
| 262 | + expect{ subject.send(:determine_package_type, nimclient_showres_output, 'bos.net.tcp.ntp', '7.2.0.2') }.to raise_error( |
| 263 | + Puppet::Error, /Unable to parse output from nimclient showres: line does not match expected package header format/) |
| 264 | + end |
223 | 265 | end
|
224 | 266 | end
|
225 | 267 | end
|
0 commit comments