test for pkg.conf before installing
This commit is contained in:
parent
1a918d557f
commit
50226a3510
|
@ -39,9 +39,11 @@ Puppet::Type.type(:package).provide :pkgng, :parent => Puppet::Provider::Package
|
|||
end
|
||||
|
||||
def install
|
||||
should = @resource.should(:ensure)
|
||||
cmd = ['install', '-qy', @resource[:name]]
|
||||
pkg(*cmd)
|
||||
if File.exists?('/usr/local/etc/pkg.conf')
|
||||
pkg(['install', '-qy', resource[:name]])
|
||||
else
|
||||
raise Puppet::Error.new("/usr/local/etc/pkg.conf does not exist")
|
||||
end
|
||||
end
|
||||
|
||||
def uninstall
|
||||
|
|
|
@ -33,6 +33,13 @@ describe provider_class do
|
|||
end
|
||||
end
|
||||
|
||||
context "#install" do
|
||||
it "should fail if pkg.conf does not exist" do
|
||||
File.stub(:exist?).with('/usr/local/etc/pkg.conf') { false }
|
||||
expect{ provider.install }.to raise_error(Puppet::Error, /pkg.conf does not exist/)
|
||||
end
|
||||
end
|
||||
|
||||
context "#query" do
|
||||
it "should return the installed version if present" do
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue