diff options
author | danielsdeleo <dan@opscode.com> | 2013-08-01 16:17:04 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-08-02 09:29:05 -0700 |
commit | 37bb9a39fefec562e517cb5f15e8e397094b0a86 (patch) | |
tree | a908119f893c511840c57f3548cf1abfac4f7654 /spec/functional/resource/package_spec.rb | |
parent | 4243345b93a5953c14a67b5f1c6e020f4f055765 (diff) | |
download | chef-37bb9a39fefec562e517cb5f15e8e397094b0a86.tar.gz |
Add additional scenarios for package tests
Adds functional test coverage for install, upgrade, remove, purge
actions when the specified package is installed at either the latest
version or at an older version.
Diffstat (limited to 'spec/functional/resource/package_spec.rb')
-rw-r--r-- | spec/functional/resource/package_spec.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/functional/resource/package_spec.rb b/spec/functional/resource/package_spec.rb index b5f8e5dc66..27d2d4ef36 100644 --- a/spec/functional/resource/package_spec.rb +++ b/spec/functional/resource/package_spec.rb @@ -286,8 +286,76 @@ describe Chef::Resource::Package, metadata do end end + end # installing w/ preseed + end # when package not installed + context "and the desired version of the package is installed" do + + before do + v_1_1_package = File.expand_path("apt/chef-integration-test_1.1-1_amd64.deb", CHEF_SPEC_DATA) + shell_out!("dpkg -i #{v_1_1_package}") + end + + it "does nothing for action :install" do + package_resource.run_action(:install) + shell_out!("dpkg -l chef-integration-test", :returns => [0]) + package_resource.should_not be_updated_by_last_action + end + + it "does nothing for action :upgrade" do + package_resource.run_action(:upgrade) + shell_out!("dpkg -l chef-integration-test", :returns => [0]) + package_resource.should_not be_updated_by_last_action + end + + it "removes the package for action :remove" do + package_resource.run_action(:remove) + shell_out!("dpkg -l chef-integration-test", :returns => [1]) + package_resource.should be_updated_by_last_action + end + + it "removes the package for action :purge" do + package_resource.run_action(:purge) + shell_out!("dpkg -l chef-integration-test", :returns => [1]) + package_resource.should be_updated_by_last_action + end + + end + + context "and an older version of the package is installed" do + before do + v_1_0_package = File.expand_path("apt/chef-integration-test_1.0-1_amd64.deb", CHEF_SPEC_DATA) + shell_out!("dpkg -i #{v_1_0_package}") + end + + it "does nothing for action :install" do + package_resource.run_action(:install) + shell_out!("dpkg -l chef-integration-test", :returns => [0]) + package_resource.should_not be_updated_by_last_action + end + + it "upgrades the package for action :upgrade" do + package_resource.run_action(:upgrade) + dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0]) + dpkg_l.stdout.should =~ /chef\-integration\-test[\s]+1\.1\-1/ + package_resource.should be_updated_by_last_action + end + + context "and the resource specifies the new version" do + let(:package_resource) do + r = base_resource + r.version("1.1-1") + r + end + + it "upgrades the package for action :install" do + package_resource.run_action(:install) + dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0]) + dpkg_l.stdout.should =~ /chef\-integration\-test[\s]+1\.1\-1/ + package_resource.should be_updated_by_last_action + end end + end end |