summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider/package/apt_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/package/apt_spec.rb')
-rwxr-xr-xspec/unit/provider/package/apt_spec.rb188
1 files changed, 94 insertions, 94 deletions
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index 54f2c0771..3c6bf62af 100755
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -5,141 +5,141 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f
provider = Puppet::Type.type(:package).provider(:apt)
describe provider do
- before do
- @resource = stub 'resource', :[] => "asdf"
- @provider = provider.new(@resource)
+ before do
+ @resource = stub 'resource', :[] => "asdf"
+ @provider = provider.new(@resource)
- @fakeresult = "install ok installed asdf 1.0\n"
- end
+ @fakeresult = "install ok installed asdf 1.0\n"
+ end
- it "should be versionable" do
- provider.should be_versionable
- end
+ it "should be versionable" do
+ provider.should be_versionable
+ end
- it "should use :install to update" do
- @provider.expects(:install)
- @provider.update
- end
+ it "should use :install to update" do
+ @provider.expects(:install)
+ @provider.update
+ end
- it "should use 'apt-get remove' to uninstall" do
- @provider.expects(:aptget).with("-y", "-q", :remove, "asdf")
+ it "should use 'apt-get remove' to uninstall" do
+ @provider.expects(:aptget).with("-y", "-q", :remove, "asdf")
- @provider.uninstall
- end
+ @provider.uninstall
+ end
- it "should use 'apt-get purge' and 'dpkg purge' to purge" do
- @provider.expects(:aptget).with("-y", "-q", :remove, "--purge", "asdf")
- @provider.expects(:dpkg).with("--purge", "asdf")
+ it "should use 'apt-get purge' and 'dpkg purge' to purge" do
+ @provider.expects(:aptget).with("-y", "-q", :remove, "--purge", "asdf")
+ @provider.expects(:dpkg).with("--purge", "asdf")
- @provider.purge
- end
+ @provider.purge
+ end
- it "should use 'apt-cache policy' to determine the latest version of a package" do
- @provider.expects(:aptcache).with(:policy, "asdf").returns "asdf:
+ it "should use 'apt-cache policy' to determine the latest version of a package" do
+ @provider.expects(:aptcache).with(:policy, "asdf").returns "asdf:
Installed: 1:1.0
Candidate: 1:1.1
Version table:
1:1.0
- 650 http://ftp.osuosl.org testing/main Packages
+ 650 http://ftp.osuosl.org testing/main Packages
*** 1:1.1
- 100 /var/lib/dpkg/status"
+ 100 /var/lib/dpkg/status"
- @provider.latest.should == "1:1.1"
- end
+ @provider.latest.should == "1:1.1"
+ end
- it "should print and error and return nil if no policy is found" do
- @provider.expects(:aptcache).with(:policy, "asdf").returns "asdf:"
+ it "should print and error and return nil if no policy is found" do
+ @provider.expects(:aptcache).with(:policy, "asdf").returns "asdf:"
- @provider.expects(:err)
- @provider.latest.should be_nil
- end
+ @provider.expects(:err)
+ @provider.latest.should be_nil
+ end
- it "should be able to preseed" do
- @provider.should respond_to(:run_preseed)
- end
+ it "should be able to preseed" do
+ @provider.should respond_to(:run_preseed)
+ end
- it "should preseed with the provided responsefile when preseeding is called for" do
- @resource.expects(:[]).with(:responsefile).returns "/my/file"
- FileTest.expects(:exist?).with("/my/file").returns true
+ it "should preseed with the provided responsefile when preseeding is called for" do
+ @resource.expects(:[]).with(:responsefile).returns "/my/file"
+ FileTest.expects(:exist?).with("/my/file").returns true
- @provider.expects(:info)
- @provider.expects(:preseed).with("/my/file")
+ @provider.expects(:info)
+ @provider.expects(:preseed).with("/my/file")
- @provider.run_preseed
- end
+ @provider.run_preseed
+ end
- it "should not preseed if no responsefile is provided" do
- @resource.expects(:[]).with(:responsefile).returns nil
+ it "should not preseed if no responsefile is provided" do
+ @resource.expects(:[]).with(:responsefile).returns nil
- @provider.expects(:info)
- @provider.expects(:preseed).never
+ @provider.expects(:info)
+ @provider.expects(:preseed).never
- @provider.run_preseed
- end
+ @provider.run_preseed
+ end
- it "should fail if a cdrom is listed in the sources list and :allowcdrom is not specified"
+ it "should fail if a cdrom is listed in the sources list and :allowcdrom is not specified"
- describe "when installing" do
- it "should preseed if a responsefile is provided" do
- @resource.expects(:[]).with(:responsefile).returns "/my/file"
- @provider.expects(:run_preseed)
+ describe "when installing" do
+ it "should preseed if a responsefile is provided" do
+ @resource.expects(:[]).with(:responsefile).returns "/my/file"
+ @provider.expects(:run_preseed)
- @provider.stubs(:aptget)
- @provider.install
- end
+ @provider.stubs(:aptget)
+ @provider.install
+ end
- it "should check for a cdrom" do
- @provider.expects(:checkforcdrom)
+ it "should check for a cdrom" do
+ @provider.expects(:checkforcdrom)
- @provider.stubs(:aptget)
- @provider.install
- end
+ @provider.stubs(:aptget)
+ @provider.install
+ end
- it "should use 'apt-get install' with the package name if no version is asked for" do
- @resource.expects(:[]).with(:ensure).returns :installed
- @provider.expects(:aptget).with { |*command| command[-1] == "asdf" and command[-2] == :install }
+ it "should use 'apt-get install' with the package name if no version is asked for" do
+ @resource.expects(:[]).with(:ensure).returns :installed
+ @provider.expects(:aptget).with { |*command| command[-1] == "asdf" and command[-2] == :install }
- @provider.install
- end
+ @provider.install
+ end
- it "should specify the package version if one is asked for" do
- @resource.expects(:[]).with(:ensure).returns "1.0"
- @provider.expects(:aptget).with { |*command| command[-1] == "asdf=1.0" }
+ it "should specify the package version if one is asked for" do
+ @resource.expects(:[]).with(:ensure).returns "1.0"
+ @provider.expects(:aptget).with { |*command| command[-1] == "asdf=1.0" }
- @provider.install
- end
+ @provider.install
+ end
- it "should use --force-yes if a package version is specified" do
- @resource.expects(:[]).with(:ensure).returns "1.0"
- @provider.expects(:aptget).with { |*command| command.include?("--force-yes") }
+ it "should use --force-yes if a package version is specified" do
+ @resource.expects(:[]).with(:ensure).returns "1.0"
+ @provider.expects(:aptget).with { |*command| command.include?("--force-yes") }
- @provider.install
- end
+ @provider.install
+ end
- it "should do a quiet install" do
- @provider.expects(:aptget).with { |*command| command.include?("-q") }
+ it "should do a quiet install" do
+ @provider.expects(:aptget).with { |*command| command.include?("-q") }
- @provider.install
- end
+ @provider.install
+ end
- it "should default to 'yes' for all questions" do
- @provider.expects(:aptget).with { |*command| command.include?("-y") }
+ it "should default to 'yes' for all questions" do
+ @provider.expects(:aptget).with { |*command| command.include?("-y") }
- @provider.install
- end
+ @provider.install
+ end
- it "should keep config files if asked" do
- @resource.expects(:[]).with(:configfiles).returns :keep
- @provider.expects(:aptget).with { |*command| command.include?("DPkg::Options::=--force-confold") }
+ it "should keep config files if asked" do
+ @resource.expects(:[]).with(:configfiles).returns :keep
+ @provider.expects(:aptget).with { |*command| command.include?("DPkg::Options::=--force-confold") }
- @provider.install
- end
+ @provider.install
+ end
- it "should replace config files if asked" do
- @resource.expects(:[]).with(:configfiles).returns :replace
- @provider.expects(:aptget).with { |*command| command.include?("DPkg::Options::=--force-confnew") }
+ it "should replace config files if asked" do
+ @resource.expects(:[]).with(:configfiles).returns :replace
+ @provider.expects(:aptget).with { |*command| command.include?("DPkg::Options::=--force-confnew") }
- @provider.install
- end
+ @provider.install
end
+ end
end