chef 12.5.1-universal-mingw32 → 12.6.0-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +6 -1
- data/README.md +6 -4
- data/Rakefile +1 -4
- data/chef-windows.gemspec +21 -0
- data/chef.gemspec +58 -0
- data/lib/chef/api_client/registration.rb +9 -4
- data/lib/chef/application.rb +3 -84
- data/lib/chef/application/apply.rb +9 -2
- data/lib/chef/application/client.rb +8 -3
- data/lib/chef/application/solo.rb +7 -1
- data/lib/chef/application/windows_service.rb +21 -6
- data/lib/chef/application/windows_service_manager.rb +2 -3
- data/lib/chef/audit/runner.rb +1 -0
- data/lib/chef/chef_class.rb +1 -11
- data/lib/chef/chef_fs/chef_fs_data_store.rb +181 -2
- data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +5 -0
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +11 -7
- data/lib/chef/client.rb +28 -1
- data/lib/chef/cookbook/cookbook_collection.rb +14 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +115 -9
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/digester.rb +5 -1
- data/lib/chef/dsl/chef_provisioning.rb +57 -0
- data/lib/chef/dsl/cheffish.rb +64 -0
- data/lib/chef/dsl/declare_resource.rb +108 -0
- data/lib/chef/dsl/platform_introspection.rb +3 -3
- data/lib/chef/dsl/recipe.rb +3 -73
- data/lib/chef/dsl/resources.rb +27 -1
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +5 -0
- data/lib/chef/event_dispatch/events_output_stream.rb +8 -0
- data/lib/chef/exceptions.rb +21 -1
- data/lib/chef/file_access_control/unix.rb +12 -12
- data/lib/chef/file_content_management/deploy/cp.rb +2 -2
- data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/indentable_output_stream.rb +5 -0
- data/lib/chef/http.rb +19 -3
- data/lib/chef/http/decompressor.rb +2 -2
- data/lib/chef/json_compat.rb +1 -0
- data/lib/chef/knife.rb +16 -2
- data/lib/chef/knife/bootstrap.rb +55 -10
- data/lib/chef/knife/cookbook_site_install.rb +5 -1
- data/lib/chef/knife/core/bootstrap_context.rb +2 -1
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +30 -16
- data/lib/chef/knife/ssl_check.rb +4 -2
- data/lib/chef/knife/ssl_fetch.rb +3 -2
- data/lib/chef/knife/status.rb +14 -1
- data/lib/chef/log.rb +14 -0
- data/lib/chef/mixin/get_source_from_package.rb +7 -2
- data/lib/chef/mixin/properties.rb +302 -0
- data/lib/chef/mixin/proxified_socket.rb +38 -0
- data/lib/chef/mixin/subclass_directive.rb +37 -0
- data/lib/chef/node.rb +13 -5
- data/lib/chef/platform/query_helpers.rb +14 -3
- data/lib/chef/platform/service_helpers.rb +20 -38
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +51 -12
- data/lib/chef/provider.rb +40 -35
- data/lib/chef/provider/deploy.rb +1 -1
- data/lib/chef/provider/dsc_resource.rb +54 -20
- data/lib/chef/provider/execute.rb +25 -4
- data/lib/chef/provider/group.rb +1 -1
- data/lib/chef/provider/lwrp_base.rb +1 -0
- data/lib/chef/provider/package.rb +76 -30
- data/lib/chef/provider/package/dpkg.rb +152 -69
- data/lib/chef/provider/package/openbsd.rb +6 -8
- data/lib/chef/provider/package/solaris.rb +2 -0
- data/lib/chef/provider/package/windows.rb +95 -14
- data/lib/chef/provider/package/windows/exe.rb +129 -0
- data/lib/chef/provider/package/windows/msi.rb +37 -13
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +89 -0
- data/lib/chef/provider/package/yum.rb +13 -3
- data/lib/chef/provider/powershell_script.rb +3 -0
- data/lib/chef/provider/remote_file/cache_control_data.rb +37 -4
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/script.rb +1 -0
- data/lib/chef/provider/service.rb +13 -10
- data/lib/chef/provider/service/solaris.rb +43 -17
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +111 -100
- data/lib/chef/provider/user/windows.rb +5 -3
- data/lib/chef/recipe.rb +3 -5
- data/lib/chef/resource.rb +77 -320
- data/lib/chef/resource/action_class.rb +4 -0
- data/lib/chef/resource/dpkg_package.rb +4 -3
- data/lib/chef/resource/dsc_resource.rb +40 -2
- data/lib/chef/resource/execute.rb +9 -1
- data/lib/chef/resource/ksh.rb +32 -0
- data/lib/chef/resource/lwrp_base.rb +6 -10
- data/lib/chef/resource/package.rb +8 -9
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/resource_notification.rb +14 -1
- data/lib/chef/resource/script.rb +1 -1
- data/lib/chef/resource/windows_package.rb +1 -1
- data/lib/chef/resource_builder.rb +14 -7
- data/lib/chef/resource_reporter.rb +6 -0
- data/lib/chef/resources.rb +1 -7
- data/lib/chef/rest.rb +1 -1
- data/lib/chef/run_context.rb +45 -2
- data/lib/chef/run_list/run_list_expansion.rb +47 -0
- data/lib/chef/runner.rb +25 -0
- data/lib/chef/search/query.rb +16 -2
- data/lib/chef/util/diff.rb +2 -2
- data/lib/chef/util/powershell/ps_credential.rb +2 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +51 -1
- data/lib/chef/win32/file.rb +5 -0
- data/lib/chef/win32/file/version_info.rb +93 -0
- data/lib/chef/win32/mutex.rb +1 -1
- data/spec/data/apt/chef-integration-test2-1.0/debian/changelog +5 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.debhelper.log +45 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.substvars +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/control +10 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/md5sums +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/control +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/files +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.debian.tar.gz +0 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.dsc +18 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.build +91 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.changes +31 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test2_1.0.orig.tar.gz +0 -0
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +4 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/notifications_spec.rb +74 -4
- data/spec/functional/resource/aix_service_spec.rb +2 -2
- data/spec/functional/resource/dpkg_package_spec.rb +339 -0
- data/spec/functional/resource/ifconfig_spec.rb +3 -1
- data/spec/functional/resource/mount_spec.rb +5 -2
- data/spec/functional/resource/package_spec.rb +1 -1
- data/spec/functional/resource/user/windows_spec.rb +8 -0
- data/spec/functional/resource/windows_package_spec.rb +177 -0
- data/spec/functional/win32/version_info_spec.rb +50 -0
- data/spec/integration/client/client_spec.rb +80 -0
- data/spec/integration/knife/download_spec.rb +9 -0
- data/spec/integration/knife/upload_spec.rb +28 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +93 -23
- data/spec/integration/recipes/resource_action_spec.rb +211 -116
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +72 -0
- data/spec/integration/solo/solo_spec.rb +34 -0
- data/spec/spec_helper.rb +11 -1
- data/spec/support/platform_helpers.rb +8 -0
- data/spec/support/shared/integration/integration_helper.rb +6 -0
- data/spec/support/shared/unit/execute_resource.rb +5 -0
- data/spec/support/shared/unit/platform_introspector.rb +7 -0
- data/spec/tiny_server.rb +6 -2
- data/spec/unit/api_client/registration_spec.rb +5 -4
- data/spec/unit/application_spec.rb +1 -181
- data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +34 -0
- data/spec/unit/cookbook/metadata_spec.rb +122 -2
- data/spec/unit/http_spec.rb +102 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -13
- data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -3
- data/spec/unit/knife/ssl_check_spec.rb +7 -3
- data/spec/unit/knife/ssl_fetch_spec.rb +2 -2
- data/spec/unit/knife/status_spec.rb +13 -13
- data/spec/unit/knife_spec.rb +26 -2
- data/spec/unit/lwrp_spec.rb +1 -1
- data/spec/unit/mixin/properties_spec.rb +97 -0
- data/spec/unit/mixin/proxified_socket_spec.rb +94 -0
- data/spec/unit/mixin/subclass_directive_spec.rb +45 -0
- data/spec/unit/node_spec.rb +9 -1
- data/spec/unit/policy_builder/policyfile_spec.rb +2 -0
- data/spec/unit/property/validation_spec.rb +14 -12
- data/spec/unit/property_spec.rb +56 -0
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/dsc_resource_spec.rb +63 -24
- data/spec/unit/provider/execute_spec.rb +95 -28
- data/spec/unit/provider/package/dpkg_spec.rb +185 -96
- data/spec/unit/provider/package/windows/exe_spec.rb +251 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +94 -10
- data/spec/unit/provider/package/windows_spec.rb +227 -26
- data/spec/unit/provider/package/yum_spec.rb +6 -0
- data/spec/unit/provider/package_spec.rb +495 -366
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +62 -36
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +110 -39
- data/spec/unit/provider/service/upstart_service_spec.rb +19 -0
- data/spec/unit/provider/user/dscl_spec.rb +14 -0
- data/spec/unit/provider/user/windows_spec.rb +2 -2
- data/spec/unit/provider/user_spec.rb +9 -0
- data/spec/unit/provider_resolver_spec.rb +6 -30
- data/spec/unit/recipe_spec.rb +46 -20
- data/spec/unit/resource/chef_gem_spec.rb +1 -1
- data/spec/unit/resource/dsc_resource_spec.rb +14 -3
- data/spec/unit/resource/ksh_spec.rb +40 -0
- data/spec/unit/resource/registry_key_spec.rb +2 -2
- data/spec/unit/resource/resource_notification_spec.rb +44 -45
- data/spec/unit/resource_reporter_spec.rb +7 -0
- data/spec/unit/resource_spec.rb +268 -253
- data/spec/unit/rest_spec.rb +2 -2
- data/spec/unit/run_list/run_list_expansion_spec.rb +18 -3
- data/spec/unit/search/query_spec.rb +19 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +8 -1
- data/spec/unit/windows_service_spec.rb +83 -38
- data/tasks/external_tests.rb +19 -9
- data/tasks/rspec.rb +1 -1
- metadata +70 -21
- data/spec/support/pedant/Gemfile +0 -3
- data/spec/support/pedant/pedant_config.rb +0 -129
- data/spec/support/pedant/run_pedant.rb +0 -63
- data/spec/support/pedant/stickywicket.pem +0 -27
- data/spec/unit/provider/package_spec.rbe +0 -0
data/spec/unit/property_spec.rb
CHANGED
@@ -921,6 +921,9 @@ describe "Chef::Resource.property" do
|
|
921
921
|
expect(resource.x 10).to eq "101"
|
922
922
|
expect(Namer.current_index).to eq 1
|
923
923
|
end
|
924
|
+
it "does not emit a deprecation warning if set to nil" do
|
925
|
+
expect(resource.x nil).to eq "1"
|
926
|
+
end
|
924
927
|
it "coercion sets the value (and coercion does not run on get)" do
|
925
928
|
expect(resource.x 10).to eq "101"
|
926
929
|
expect(resource.x).to eq "101"
|
@@ -933,6 +936,11 @@ describe "Chef::Resource.property" do
|
|
933
936
|
expect(Namer.current_index).to eq 2
|
934
937
|
end
|
935
938
|
end
|
939
|
+
with_property ':x, coerce: proc { |x| x }' do
|
940
|
+
it "does not emit a deprecation warning if set to nil" do
|
941
|
+
expect(resource.x nil).to be_nil
|
942
|
+
end
|
943
|
+
end
|
936
944
|
with_property ':x, coerce: proc { |x| Namer.next_index; raise "hi" if x == 10; x }, is: proc { |x| Namer.next_index; x != 10 }' do
|
937
945
|
it "failed coercion fails to set the value" do
|
938
946
|
resource.x 20
|
@@ -1091,4 +1099,52 @@ describe "Chef::Resource.property" do
|
|
1091
1099
|
expect { resource_class.property :x, :name_property => true, :name_attribute => true }.to raise_error ArgumentError,
|
1092
1100
|
/Cannot specify both name_property and name_attribute together on property x of resource chef_resource_property_spec_(\d+)./
|
1093
1101
|
end
|
1102
|
+
|
1103
|
+
context "with a custom property type" do
|
1104
|
+
class CustomPropertyType < Chef::Property
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
with_property ":x, CustomPropertyType.new" do
|
1108
|
+
it "creates x with the given type" do
|
1109
|
+
expect(resource_class.properties[:x]).to be_kind_of(CustomPropertyType)
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
context "and a subclass" do
|
1113
|
+
let(:subresource_class) do
|
1114
|
+
new_resource_name = self.class.new_resource_name
|
1115
|
+
Class.new(resource_class) do
|
1116
|
+
resource_name new_resource_name
|
1117
|
+
end
|
1118
|
+
end
|
1119
|
+
let(:subresource) do
|
1120
|
+
subresource_class.new('blah')
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
context "with property :x, default: 10 on the subclass" do
|
1124
|
+
before do
|
1125
|
+
subresource_class.class_eval do
|
1126
|
+
property :x, default: 10
|
1127
|
+
end
|
1128
|
+
end
|
1129
|
+
|
1130
|
+
it "x has the given type and default on the subclass" do
|
1131
|
+
expect(subresource_class.properties[:x]).to be_kind_of(CustomPropertyType)
|
1132
|
+
expect(subresource_class.properties[:x].default).to eq(10)
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
it "x does not have the default on the superclass" do
|
1136
|
+
expect(resource_class.properties[:x]).to be_kind_of(CustomPropertyType)
|
1137
|
+
expect(resource_class.properties[:x].default).to be_nil
|
1138
|
+
end
|
1139
|
+
end
|
1140
|
+
end
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
with_property ":x, CustomPropertyType.new, default: 10" do
|
1144
|
+
it "passes the default to the custom property type" do
|
1145
|
+
expect(resource_class.properties[:x]).to be_kind_of(CustomPropertyType)
|
1146
|
+
expect(resource_class.properties[:x].default).to eq(10)
|
1147
|
+
end
|
1148
|
+
end
|
1149
|
+
end
|
1094
1150
|
end
|
@@ -356,7 +356,7 @@ describe Chef::Provider::Deploy do
|
|
356
356
|
it "chowns the whole release dir to user and group specified in the resource" do
|
357
357
|
@resource.user "foo"
|
358
358
|
@resource.group "bar"
|
359
|
-
expect(FileUtils).to receive(:chown_R).with("foo", "bar", "/my/deploy/dir")
|
359
|
+
expect(FileUtils).to receive(:chown_R).with("foo", "bar", "/my/deploy/dir", { :force => true })
|
360
360
|
@provider.enforce_ownership
|
361
361
|
end
|
362
362
|
|
@@ -16,7 +16,6 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
|
-
|
20
19
|
require 'chef'
|
21
20
|
require 'spec_helper'
|
22
21
|
|
@@ -34,7 +33,6 @@ describe Chef::Provider::DscResource do
|
|
34
33
|
node.automatic[:languages][:powershell][:version] = '4.0'
|
35
34
|
node
|
36
35
|
}
|
37
|
-
|
38
36
|
it 'raises a ProviderNotFound exception' do
|
39
37
|
expect(provider).not_to receive(:meta_configuration)
|
40
38
|
expect{provider.run_action(:run)}.to raise_error(
|
@@ -43,35 +41,76 @@ describe Chef::Provider::DscResource do
|
|
43
41
|
end
|
44
42
|
|
45
43
|
context 'when Powershell supports Invoke-DscResource' do
|
44
|
+
|
45
|
+
context 'when RefreshMode is not set to Disabled' do
|
46
|
+
context 'and the WMF 5 is a preview release' do
|
47
|
+
let (:node) {
|
48
|
+
node = Chef::Node.new
|
49
|
+
node.automatic[:languages][:powershell][:version] = '5.0.10018.0'
|
50
|
+
node
|
51
|
+
}
|
52
|
+
it 'raises an exception' do
|
53
|
+
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false)
|
54
|
+
expect { provider.run_action(:run) }.to raise_error(
|
55
|
+
Chef::Exceptions::ProviderNotFound, /Disabled/)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
context 'and the WMF is 5 RTM or newer' do
|
59
|
+
let (:node) {
|
60
|
+
node = Chef::Node.new
|
61
|
+
node.automatic[:languages][:powershell][:version] = '5.0.10586.0'
|
62
|
+
node
|
63
|
+
}
|
64
|
+
it 'does not raises an exception' do
|
65
|
+
expect(provider).to receive(:test_resource)
|
66
|
+
expect(provider).to receive(:set_resource)
|
67
|
+
expect(provider).to receive(:reboot_if_required)
|
68
|
+
expect { provider.run_action(:run) }.to_not raise_error
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when the LCM supports Invoke-DscResource' do
|
46
75
|
let (:node) {
|
47
76
|
node = Chef::Node.new
|
48
77
|
node.automatic[:languages][:powershell][:version] = '5.0.10018.0'
|
49
78
|
node
|
50
79
|
}
|
51
80
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
81
|
+
it 'does not update the resource if it is up to date' do
|
82
|
+
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
|
83
|
+
expect(provider).to receive(:test_resource).and_return(true)
|
84
|
+
provider.run_action(:run)
|
85
|
+
expect(resource).not_to be_updated
|
58
86
|
end
|
59
87
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
88
|
+
it 'converges the resource if it is not up to date' do
|
89
|
+
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
|
90
|
+
expect(provider).to receive(:test_resource).and_return(false)
|
91
|
+
expect(provider).to receive(:set_resource)
|
92
|
+
provider.run_action(:run)
|
93
|
+
expect(resource).to be_updated
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'flags the resource as reboot required when required' do
|
97
|
+
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
|
98
|
+
expect(provider).to receive(:test_resource).and_return(false)
|
99
|
+
expect(provider).to receive(:invoke_resource).
|
100
|
+
and_return(double(:stdout => '', :return_value =>nil))
|
101
|
+
expect(provider).to receive(:return_dsc_resource_result).and_return(true)
|
102
|
+
expect(provider).to receive(:create_reboot_resource)
|
103
|
+
provider.run_action(:run)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'does not flag the resource as reboot required when not required' do
|
107
|
+
expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true)
|
108
|
+
expect(provider).to receive(:test_resource).and_return(false)
|
109
|
+
expect(provider).to receive(:invoke_resource).
|
110
|
+
and_return(double(:stdout => '', :return_value =>nil))
|
111
|
+
expect(provider).to receive(:return_dsc_resource_result).and_return(false)
|
112
|
+
expect(provider).to_not receive(:create_reboot_resource)
|
113
|
+
provider.run_action(:run)
|
75
114
|
end
|
76
115
|
end
|
77
|
-
end
|
116
|
+
end
|
@@ -25,28 +25,32 @@ describe Chef::Provider::Execute do
|
|
25
25
|
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
26
26
|
let(:provider) { Chef::Provider::Execute.new(new_resource, run_context) }
|
27
27
|
let(:current_resource) { Chef::Resource::Ifconfig.new("foo_resource", run_context) }
|
28
|
+
# You will be the same object, I promise.
|
29
|
+
@live_stream = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute)
|
28
30
|
|
29
31
|
let(:opts) do
|
30
32
|
{
|
31
33
|
timeout: 3600,
|
32
34
|
returns: 0,
|
33
35
|
log_level: :info,
|
34
|
-
log_tag: new_resource.to_s
|
35
|
-
live_stream: STDOUT,
|
36
|
+
log_tag: new_resource.to_s
|
36
37
|
}
|
37
38
|
end
|
38
39
|
|
39
40
|
let(:new_resource) { Chef::Resource::Execute.new("foo_resource", run_context) }
|
40
41
|
|
41
42
|
before do
|
43
|
+
allow(Chef::EventDispatch::EventsOutputStream).to receive(:new) { @live_stream }
|
42
44
|
allow(ChefConfig).to receive(:windows?) { false }
|
43
45
|
@original_log_level = Chef::Log.level
|
44
46
|
Chef::Log.level = :info
|
45
|
-
allow(STDOUT).to receive(:tty?).and_return(
|
47
|
+
allow(STDOUT).to receive(:tty?).and_return(false)
|
46
48
|
end
|
47
49
|
|
48
50
|
after do
|
49
51
|
Chef::Log.level = @original_log_level
|
52
|
+
Chef::Config[:always_stream_execute] = false
|
53
|
+
Chef::Config[:daemon] = false
|
50
54
|
end
|
51
55
|
|
52
56
|
describe "#initialize" do
|
@@ -142,35 +146,98 @@ describe Chef::Provider::Execute do
|
|
142
146
|
expect(new_resource).not_to be_updated
|
143
147
|
end
|
144
148
|
|
145
|
-
it "should
|
146
|
-
expect(STDOUT).to receive(:tty?).and_return(false)
|
149
|
+
it "should not include stdout/stderr in failure exception for sensitive resource" do
|
147
150
|
opts.delete(:live_stream)
|
148
|
-
|
149
|
-
expect(provider).to receive(:
|
150
|
-
expect
|
151
|
-
|
152
|
-
|
151
|
+
new_resource.sensitive true
|
152
|
+
expect(provider).to receive(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
|
153
|
+
expect do
|
154
|
+
provider.run_action(:run)
|
155
|
+
end.to raise_error(Mixlib::ShellOut::ShellCommandFailed, /suppressed for sensitive resource/)
|
153
156
|
end
|
154
157
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
158
|
+
describe "streaming output" do
|
159
|
+
it "should not set the live_stream if sensitive is on" do
|
160
|
+
new_resource.sensitive true
|
161
|
+
expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
|
162
|
+
expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
|
163
|
+
expect(Chef::Log).not_to receive(:warn)
|
164
|
+
provider.run_action(:run)
|
165
|
+
expect(new_resource).to be_updated
|
166
|
+
end
|
165
167
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
168
|
+
describe "with an output formatter listening" do
|
169
|
+
let(:events) { d = Chef::EventDispatch::Dispatcher.new; d.register(Chef::Formatters::Doc.new(StringIO.new, StringIO.new)); d }
|
170
|
+
|
171
|
+
before do
|
172
|
+
Chef::Config[:stream_execute_output] = true
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should set the live_stream if the log level is info or above" do
|
176
|
+
nopts = opts
|
177
|
+
nopts[:live_stream] = @live_stream
|
178
|
+
expect(provider).to receive(:shell_out!).with(new_resource.name, nopts)
|
179
|
+
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
180
|
+
expect(Chef::Log).not_to receive(:warn)
|
181
|
+
provider.run_action(:run)
|
182
|
+
expect(new_resource).to be_updated
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should set the live_stream if the resource requests live streaming" do
|
186
|
+
Chef::Log.level = :warn
|
187
|
+
new_resource.live_stream true
|
188
|
+
nopts = opts
|
189
|
+
nopts[:live_stream] = @live_stream
|
190
|
+
expect(provider).to receive(:shell_out!).with(new_resource.name, nopts)
|
191
|
+
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
192
|
+
expect(Chef::Log).not_to receive(:warn)
|
193
|
+
provider.run_action(:run)
|
194
|
+
expect(new_resource).to be_updated
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should not set the live_stream if the resource is sensitive" do
|
198
|
+
new_resource.sensitive true
|
199
|
+
expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
|
200
|
+
expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
|
201
|
+
expect(Chef::Log).not_to receive(:warn)
|
202
|
+
provider.run_action(:run)
|
203
|
+
expect(new_resource).to be_updated
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe "with only logging enabled" do
|
208
|
+
it "should set the live_stream to STDOUT if we are a TTY, not daemonized, not sensitive, and info is enabled" do
|
209
|
+
nopts = opts
|
210
|
+
nopts[:live_stream] = STDOUT
|
211
|
+
allow(STDOUT).to receive(:tty?).and_return(true)
|
212
|
+
expect(provider).to receive(:shell_out!).with(new_resource.name, nopts)
|
213
|
+
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
214
|
+
expect(Chef::Log).not_to receive(:warn)
|
215
|
+
provider.run_action(:run)
|
216
|
+
expect(new_resource).to be_updated
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should not set the live_stream to STDOUT if we are a TTY, not daemonized, but sensitive" do
|
220
|
+
new_resource.sensitive true
|
221
|
+
allow(STDOUT).to receive(:tty?).and_return(true)
|
222
|
+
expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
|
223
|
+
expect(provider).to receive(:converge_by).with("execute sensitive resource").and_call_original
|
224
|
+
expect(Chef::Log).not_to receive(:warn)
|
225
|
+
provider.run_action(:run)
|
226
|
+
expect(new_resource).to be_updated
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should not set the live_stream to STDOUT if we are a TTY, but daemonized" do
|
230
|
+
Chef::Config[:daemon] = true
|
231
|
+
allow(STDOUT).to receive(:tty?).and_return(true)
|
232
|
+
expect(provider).to receive(:shell_out!).with(new_resource.name, opts)
|
233
|
+
expect(provider).to receive(:converge_by).with("execute foo_resource").and_call_original
|
234
|
+
expect(Chef::Log).not_to receive(:warn)
|
235
|
+
provider.run_action(:run)
|
236
|
+
expect(new_resource).to be_updated
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
174
240
|
end
|
241
|
+
|
175
242
|
end
|
176
243
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#
|
2
1
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
2
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
3
|
# License:: Apache License, Version 2.0
|
@@ -19,42 +18,109 @@
|
|
19
18
|
require 'spec_helper'
|
20
19
|
|
21
20
|
describe Chef::Provider::Package::Dpkg do
|
21
|
+
let(:node) { Chef::Node.new }
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
24
|
+
let(:package) { "wget" }
|
25
|
+
let(:source) { "/tmp/wget_1.11.4-1ubuntu1_amd64.deb" }
|
26
|
+
let(:new_resource) do
|
27
|
+
new_resource = Chef::Resource::DpkgPackage.new(package)
|
28
|
+
new_resource.source source
|
29
|
+
new_resource
|
30
|
+
end
|
31
|
+
let(:provider) { Chef::Provider::Package::Dpkg.new(new_resource, run_context) }
|
32
|
+
|
33
|
+
let(:dpkg_deb_version) { "1.11.4" }
|
34
|
+
let(:dpkg_deb_status) { status = double(:stdout => "#{package}\t#{dpkg_deb_version}", :exitstatus => 0) }
|
35
|
+
let(:dpkg_s_version) { "1.11.4-1ubuntu1" }
|
36
|
+
let(:dpkg_s_status) do
|
37
|
+
stdout = <<-DPKG_S
|
38
|
+
Package: #{package}
|
39
|
+
Status: install ok installed
|
40
|
+
Priority: important
|
41
|
+
Section: web
|
42
|
+
Installed-Size: 1944
|
43
|
+
Maintainer: Ubuntu Core developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
44
|
+
Architecture: amd64
|
45
|
+
Version: #{dpkg_s_version}
|
46
|
+
Config-Version: #{dpkg_s_version}
|
47
|
+
Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5)
|
48
|
+
Conflicts: wget-ssl
|
49
|
+
DPKG_S
|
50
|
+
status = double(:stdout => stdout, :exitstatus => 1)
|
51
|
+
end
|
52
|
+
|
22
53
|
before(:each) do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
54
|
+
allow(provider).to receive(:shell_out!).with("dpkg-deb -W #{source}", timeout: 900).and_return(dpkg_deb_status)
|
55
|
+
allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0,1]).and_return(double(stdout: "", exitstatus: 1))
|
56
|
+
allow(::File).to receive(:exist?).with(source).and_return(true)
|
57
|
+
end
|
28
58
|
|
29
|
-
|
59
|
+
describe "#define_resource_requirements" do
|
60
|
+
it "should raise an exception if a source is supplied but not found when :install" do
|
61
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
62
|
+
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should raise an exception if a source is supplied but not found when :upgrade" do
|
66
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
67
|
+
expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
|
68
|
+
end
|
30
69
|
|
31
|
-
|
32
|
-
|
70
|
+
# FIXME? we're saying we ignore source, but should supplying source on :remove or :purge be an actual error?
|
71
|
+
it "should not raise an exception if a source is supplied but not found when :remove" do
|
72
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
73
|
+
expect(provider).to receive(:action_remove)
|
74
|
+
expect { provider.run_action(:remove) }.not_to raise_error
|
75
|
+
end
|
33
76
|
|
34
|
-
|
77
|
+
it "should not raise an exception if a source is supplied but not found when :purge" do
|
78
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
79
|
+
expect(provider).to receive(:action_purge)
|
80
|
+
expect { provider.run_action(:purge) }.not_to raise_error
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should raise an exception if a source is nil when :install" do
|
84
|
+
new_resource.source nil
|
85
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
86
|
+
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should raise an exception if a source is nil when :upgrade" do
|
90
|
+
new_resource.source nil
|
91
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
92
|
+
expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should not raise an exception if a source is nil when :remove" do
|
96
|
+
new_resource.source nil
|
97
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
98
|
+
expect(provider).to receive(:action_remove)
|
99
|
+
expect { provider.run_action(:remove) }.not_to raise_error
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should not raise an exception if a source is nil when :purge" do
|
103
|
+
new_resource.source nil
|
104
|
+
allow(::File).to receive(:exist?).with(source).and_return(false)
|
105
|
+
expect(provider).to receive(:action_purge)
|
106
|
+
expect { provider.run_action(:purge) }.not_to raise_error
|
107
|
+
end
|
35
108
|
end
|
36
109
|
|
37
110
|
describe "when loading the current resource state" do
|
38
111
|
|
39
112
|
it "should create a current resource with the name of the new_resource" do
|
40
|
-
|
41
|
-
expect(
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should raise an exception if a source is supplied but not found" do
|
45
|
-
@provider.load_current_resource
|
46
|
-
@provider.define_resource_requirements
|
47
|
-
allow(::File).to receive(:exists?).and_return(false)
|
48
|
-
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
113
|
+
provider.load_current_resource
|
114
|
+
expect(provider.current_resource.package_name).to eq(["wget"])
|
49
115
|
end
|
50
116
|
|
51
117
|
describe 'gets the source package version from dpkg-deb' do
|
52
118
|
def check_version(version)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
expect(
|
57
|
-
expect(
|
119
|
+
status = double(:stdout => "wget\t#{version}", :exitstatus => 0)
|
120
|
+
expect(provider).to receive(:shell_out!).with("dpkg-deb -W #{source}", timeout: 900).and_return(status)
|
121
|
+
provider.load_current_resource
|
122
|
+
expect(provider.current_resource.package_name).to eq(["wget"])
|
123
|
+
expect(provider.candidate_version).to eq([version])
|
58
124
|
end
|
59
125
|
|
60
126
|
it 'if short version provided' do
|
@@ -74,129 +140,152 @@ describe Chef::Provider::Package::Dpkg do
|
|
74
140
|
end
|
75
141
|
end
|
76
142
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
143
|
+
describe "when the package name has `-', `+' or `.' characters" do
|
144
|
+
let(:package) { "f.o.o-pkg++2" }
|
145
|
+
|
146
|
+
it "gets the source package name from dpkg-deb correctly" do
|
147
|
+
provider.load_current_resource
|
148
|
+
expect(provider.current_resource.package_name).to eq(["f.o.o-pkg++2"])
|
149
|
+
end
|
83
150
|
end
|
84
151
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
152
|
+
describe "when the package version has `~', `-', `+' or `.' characters" do
|
153
|
+
let(:package) { "b.a.r-pkg++1" }
|
154
|
+
let(:dpkg_deb_version) { "1.2.3+3141592-1ubuntu1~lucid" }
|
155
|
+
let(:dpkg_s_version) { "1.2.3+3141592-1ubuntu1~lucid" }
|
156
|
+
|
157
|
+
it "gets the source package version from dpkg-deb correctly when the package version has `~', `-', `+' or `.' characters" do
|
158
|
+
provider.load_current_resource
|
159
|
+
expect(provider.candidate_version).to eq(['1.2.3+3141592-1ubuntu1~lucid'])
|
160
|
+
end
|
91
161
|
end
|
92
162
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
163
|
+
describe "when the source is not set" do
|
164
|
+
let(:source) { nil }
|
165
|
+
|
166
|
+
it "should raise an exception if the source is not set but we are installing" do
|
167
|
+
expect { provider.run_action(:install)}.to raise_error(Chef::Exceptions::Package)
|
168
|
+
end
|
99
169
|
end
|
100
170
|
|
101
171
|
it "should return the current version installed if found by dpkg" do
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
Section: web
|
107
|
-
Installed-Size: 1944
|
108
|
-
Maintainer: Ubuntu Core developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
109
|
-
Architecture: amd64
|
110
|
-
Version: 1.11.4-1ubuntu1
|
111
|
-
Config-Version: 1.11.4-1ubuntu1
|
112
|
-
Depends: libc6 (>= 2.8~20080505), libssl0.9.8 (>= 0.9.8f-5)
|
113
|
-
Conflicts: wget-ssl
|
114
|
-
DPKG_S
|
115
|
-
status = double(:stdout => stdout, :exitstatus => 1)
|
116
|
-
allow(@provider).to receive(:shell_out).with("dpkg -s wget", timeout: 900).and_return(status)
|
172
|
+
allow(provider).to receive(:shell_out!).with("dpkg -s #{package}", timeout: 900, returns: [0,1]).and_return(dpkg_s_status)
|
173
|
+
provider.load_current_resource
|
174
|
+
expect(provider.current_resource.version).to eq(["1.11.4-1ubuntu1"])
|
175
|
+
end
|
117
176
|
|
118
|
-
|
119
|
-
|
177
|
+
it "on new debian/ubuntu we get an exit(1) and no stdout from dpkg -s for uninstalled" do
|
178
|
+
dpkg_s_status = double(
|
179
|
+
exitstatus: 1, stdout: "", stderr: <<-EOF
|
180
|
+
dpkg-query: package '#{package}' is not installed and no information is available
|
181
|
+
Use dpkg --info (= dpkg-deb --info) to examine archive files,
|
182
|
+
and dpkg --contents (= dpkg-deb --contents) to list their contents.
|
183
|
+
EOF
|
184
|
+
)
|
185
|
+
expect(provider).to receive(:shell_out!).with("dpkg -s #{package}", returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
|
186
|
+
provider.load_current_resource
|
187
|
+
expect(provider.current_resource.version).to eq([nil])
|
120
188
|
end
|
121
189
|
|
122
|
-
it "
|
190
|
+
it "on old debian/ubuntu we get an exit(0) and we get info on stdout from dpkg -s for uninstalled" do
|
191
|
+
dpkg_s_status = double(
|
192
|
+
exitstatus: 0, stderr: "", stdout: <<-EOF
|
193
|
+
Package: #{package}
|
194
|
+
Status: unknown ok not-installed
|
195
|
+
Priority: extra
|
196
|
+
Section: ruby
|
197
|
+
EOF
|
198
|
+
)
|
199
|
+
expect(provider).to receive(:shell_out!).with("dpkg -s #{package}", returns: [0, 1], timeout: 900).and_return(dpkg_s_status)
|
200
|
+
provider.load_current_resource
|
201
|
+
expect(provider.current_resource.version).to eq([nil])
|
202
|
+
end
|
203
|
+
|
204
|
+
it "and we should raise if we get any other exit codes from dpkg -s" do
|
205
|
+
dpkg_s_status = double(
|
206
|
+
exitstatus: 3, stderr: "i am very, very angry with you. i'm very, very cross. go to your room.", stdout: ""
|
207
|
+
)
|
208
|
+
expect(provider).to receive(:shell_out!).with("dpkg -s #{package}", returns: [0, 1], timeout: 900).and_raise(Mixlib::ShellOut::ShellCommandFailed)
|
209
|
+
expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should raise an exception if dpkg-deb -W fails to run" do
|
123
213
|
status = double(:stdout => "", :exitstatus => -1)
|
124
|
-
|
125
|
-
expect {
|
214
|
+
expect(provider).to receive(:shell_out_with_timeout!).with("dpkg-deb -W /tmp/wget_1.11.4-1ubuntu1_amd64.deb").and_raise(Mixlib::ShellOut::ShellCommandFailed)
|
215
|
+
expect { provider.load_current_resource }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
|
126
216
|
end
|
127
217
|
end
|
128
218
|
|
129
219
|
describe Chef::Provider::Package::Dpkg, "install and upgrade" do
|
130
220
|
it "should run dpkg -i with the package source" do
|
131
|
-
expect(
|
132
|
-
"dpkg -i /tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
221
|
+
expect(provider).to receive(:run_noninteractive).with(
|
222
|
+
"dpkg -i", nil, "/tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
133
223
|
)
|
134
|
-
|
224
|
+
provider.load_current_resource
|
225
|
+
provider.run_action(:install)
|
135
226
|
end
|
136
227
|
|
137
228
|
it "should run dpkg -i if the package is a path and the source is nil" do
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
"dpkg -i /tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
229
|
+
new_resource.name "/tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
230
|
+
expect(provider).to receive(:run_noninteractive).with(
|
231
|
+
"dpkg -i", nil, "/tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
142
232
|
)
|
143
|
-
|
233
|
+
provider.run_action(:install)
|
144
234
|
end
|
145
235
|
|
146
236
|
it "should run dpkg -i if the package is a path and the source is nil for an upgrade" do
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
"dpkg -i /tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
237
|
+
new_resource.name "/tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
238
|
+
expect(provider).to receive(:run_noninteractive).with(
|
239
|
+
"dpkg -i", nil, "/tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
151
240
|
)
|
152
|
-
|
241
|
+
provider.run_action(:upgrade)
|
153
242
|
end
|
154
243
|
|
155
244
|
it "should run dpkg -i with the package source and options if specified" do
|
156
|
-
|
157
|
-
|
245
|
+
new_resource.options "--force-yes"
|
246
|
+
expect(provider).to receive(:run_noninteractive).with(
|
247
|
+
"dpkg -i", "--force-yes", "/tmp/wget_1.11.4-1ubuntu1_amd64.deb"
|
158
248
|
)
|
159
|
-
|
160
|
-
|
161
|
-
@provider.install_package("wget", "1.11.4-1ubuntu1")
|
249
|
+
provider.run_action(:install)
|
162
250
|
end
|
251
|
+
|
163
252
|
it "should upgrade by running install_package" do
|
164
|
-
expect(
|
165
|
-
|
253
|
+
expect(provider).to receive(:install_package).with(["wget"], ["1.11.4-1ubuntu1"])
|
254
|
+
provider.upgrade_package(["wget"], ["1.11.4-1ubuntu1"])
|
166
255
|
end
|
167
256
|
end
|
168
257
|
|
169
258
|
describe Chef::Provider::Package::Dpkg, "remove and purge" do
|
170
259
|
it "should run dpkg -r to remove the package" do
|
171
|
-
expect(
|
172
|
-
"dpkg -r wget"
|
260
|
+
expect(provider).to receive(:run_noninteractive).with(
|
261
|
+
"dpkg -r", nil, "wget"
|
173
262
|
)
|
174
|
-
|
263
|
+
provider.remove_package(["wget"], ["1.11.4-1ubuntu1"])
|
175
264
|
end
|
176
265
|
|
177
266
|
it "should run dpkg -r to remove the package with options if specified" do
|
178
|
-
expect(
|
179
|
-
"dpkg -r --force-yes wget"
|
267
|
+
expect(provider).to receive(:run_noninteractive).with(
|
268
|
+
"dpkg -r", "--force-yes", "wget"
|
180
269
|
)
|
181
|
-
allow(
|
270
|
+
allow(new_resource).to receive(:options).and_return("--force-yes")
|
182
271
|
|
183
|
-
|
272
|
+
provider.remove_package(["wget"], ["1.11.4-1ubuntu1"])
|
184
273
|
end
|
185
274
|
|
186
275
|
it "should run dpkg -P to purge the package" do
|
187
|
-
expect(
|
188
|
-
"dpkg -P wget"
|
276
|
+
expect(provider).to receive(:run_noninteractive).with(
|
277
|
+
"dpkg -P", nil, "wget"
|
189
278
|
)
|
190
|
-
|
279
|
+
provider.purge_package(["wget"], ["1.11.4-1ubuntu1"])
|
191
280
|
end
|
192
281
|
|
193
282
|
it "should run dpkg -P to purge the package with options if specified" do
|
194
|
-
expect(
|
195
|
-
"dpkg -P --force-yes wget"
|
283
|
+
expect(provider).to receive(:run_noninteractive).with(
|
284
|
+
"dpkg -P", "--force-yes", "wget"
|
196
285
|
)
|
197
|
-
allow(
|
286
|
+
allow(new_resource).to receive(:options).and_return("--force-yes")
|
198
287
|
|
199
|
-
|
288
|
+
provider.purge_package(["wget"], ["1.11.4-1ubuntu1"])
|
200
289
|
end
|
201
290
|
end
|
202
291
|
end
|