chef 16.2.50 → 16.2.73
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -15
- data/chef.gemspec +2 -2
- data/lib/chef/application/apply.rb +1 -0
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +2 -2
- data/lib/chef/digester.rb +3 -2
- data/lib/chef/file_access_control/windows.rb +2 -2
- data/lib/chef/file_content_management/deploy/mv_unix.rb +1 -1
- data/lib/chef/http.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +12 -3
- data/lib/chef/knife/cookbook_upload.rb +1 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +1 -1
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/windows_user_privilege.rb +25 -2
- data/lib/chef/version.rb +1 -1
- data/spec/functional/knife/configure_spec.rb +1 -1
- data/spec/functional/resource/aix_service_spec.rb +10 -1
- data/spec/functional/resource/aixinit_service_spec.rb +1 -1
- data/spec/functional/resource/bash_spec.rb +3 -2
- data/spec/functional/resource/bff_spec.rb +1 -1
- data/spec/functional/resource/chocolatey_package_spec.rb +4 -0
- data/spec/functional/resource/cron_spec.rb +10 -1
- data/spec/functional/resource/dnf_package_spec.rb +4 -1
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +9 -1
- data/spec/functional/resource/ifconfig_spec.rb +9 -1
- data/spec/functional/resource/insserv_spec.rb +3 -2
- data/spec/functional/resource/link_spec.rb +2 -5
- data/spec/functional/resource/mount_spec.rb +9 -1
- data/spec/functional/resource/msu_package_spec.rb +9 -3
- data/spec/functional/resource/powershell_script_spec.rb +4 -4
- data/spec/functional/resource/remote_file_spec.rb +6 -6
- data/spec/functional/resource/rpm_spec.rb +1 -1
- data/spec/functional/resource/timezone_spec.rb +2 -0
- data/spec/functional/resource/windows_package_spec.rb +0 -1
- data/spec/functional/resource/windows_path_spec.rb +4 -0
- data/spec/functional/resource/windows_security_policy_spec.rb +0 -1
- data/spec/functional/resource/windows_service_spec.rb +4 -0
- data/spec/functional/resource/windows_task_spec.rb +4 -3
- data/spec/functional/resource/windows_user_privilege_spec.rb +0 -1
- data/spec/functional/resource/yum_package_spec.rb +4 -1
- data/spec/functional/resource/zypper_package_spec.rb +4 -1
- data/spec/functional/shell_spec.rb +0 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/integration/knife/cookbook_upload_spec.rb +1 -1
- data/spec/integration/knife/data_bag_from_file_spec.rb +1 -1
- data/spec/integration/knife/environment_from_file_spec.rb +1 -1
- data/spec/integration/knife/node_from_file_spec.rb +1 -1
- data/spec/integration/knife/role_from_file_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +4 -0
- data/spec/integration/recipes/resource_load_spec.rb +2 -2
- data/spec/support/shared/functional/securable_resource.rb +1 -2
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +0 -1
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/support/shared/unit/provider/file.rb +12 -8
- data/spec/unit/application/solo_spec.rb +4 -2
- data/spec/unit/chef_fs/config_spec.rb +2 -2
- data/spec/unit/chef_fs/diff_spec.rb +8 -8
- data/spec/unit/client_spec.rb +4 -1
- data/spec/unit/cookbook/synchronizer_spec.rb +26 -24
- data/spec/unit/data_bag_spec.rb +6 -3
- data/spec/unit/decorator_spec.rb +23 -23
- data/spec/unit/environment_spec.rb +5 -1
- data/spec/unit/guard_interpreter_spec.rb +1 -1
- data/spec/unit/http/api_versions_spec.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +1 -0
- data/spec/unit/knife/cookbook_download_spec.rb +2 -2
- data/spec/unit/knife/cookbook_show_spec.rb +6 -7
- data/spec/unit/knife/data_bag_edit_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +5 -2
- data/spec/unit/mixin/powershell_out_spec.rb +2 -4
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +1 -1
- data/spec/unit/mixin/subclass_directive_spec.rb +2 -2
- data/spec/unit/mixin/unformatter_spec.rb +2 -2
- data/spec/unit/mixin/uris_spec.rb +1 -1
- data/spec/unit/provider/batch_spec.rb +1 -1
- data/spec/unit/provider/cron/unix_spec.rb +1 -1
- data/spec/unit/provider/dsc_resource_spec.rb +22 -38
- data/spec/unit/provider/dsc_script_spec.rb +10 -10
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/git_spec.rb +3 -3
- data/spec/unit/provider/mdadm_spec.rb +1 -3
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/pacman_spec.rb +17 -20
- data/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb +3 -3
- data/spec/unit/provider/user/dscl_spec.rb +2 -2
- data/spec/unit/provider/windows_env_spec.rb +5 -4
- data/spec/unit/resource/chef_client_cron_spec.rb +23 -7
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +7 -4
- data/spec/unit/resource/file/verification_spec.rb +2 -1
- data/spec/unit/resource_spec.rb +25 -8
- data/spec/unit/role_spec.rb +23 -21
- data/spec/unit/util/backup_spec.rb +1 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +2 -2
- data/spec/unit/util/selinux_spec.rb +2 -1
- metadata +20 -15
- data/spec/functional/resource/base.rb +0 -28
@@ -16,7 +16,6 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
# rename to cookbook not coookbook
|
20
19
|
require "spec_helper"
|
21
20
|
|
22
21
|
describe Chef::Knife::CookbookShow do
|
@@ -28,24 +27,24 @@ describe Chef::Knife::CookbookShow do
|
|
28
27
|
allow(Chef::CookbookVersion).to receive(:load).and_return(cb)
|
29
28
|
end
|
30
29
|
|
31
|
-
let
|
30
|
+
let(:knife) do
|
32
31
|
knife = Chef::Knife::CookbookShow.new
|
33
32
|
knife.config = {}
|
34
33
|
knife.name_args = [ "cookbook_name" ]
|
35
34
|
knife
|
36
35
|
end
|
37
36
|
|
38
|
-
let
|
37
|
+
let(:cb) do
|
39
38
|
cb = Chef::CookbookVersion.new("cookbook_name")
|
40
39
|
cb.manifest = manifest
|
41
40
|
cb
|
42
41
|
end
|
43
42
|
|
44
|
-
let
|
43
|
+
let(:rest) { double(Chef::ServerAPI) }
|
45
44
|
|
46
|
-
let
|
45
|
+
let(:content) { "Example recipe text" }
|
47
46
|
|
48
|
-
let
|
47
|
+
let(:manifest) do
|
49
48
|
{
|
50
49
|
"all_files" => [
|
51
50
|
{
|
@@ -69,7 +68,7 @@ describe Chef::Knife::CookbookShow do
|
|
69
68
|
end
|
70
69
|
|
71
70
|
describe "with 1 argument: versions" do
|
72
|
-
let
|
71
|
+
let(:response) do
|
73
72
|
{
|
74
73
|
"cookbook_name" => {
|
75
74
|
"url" => "http://url/cookbooks/cookbook_name",
|
@@ -95,7 +95,7 @@ describe Chef::Knife::DataBagEdit do
|
|
95
95
|
let(:is_encrypted?) { true }
|
96
96
|
let(:db) { Chef::DataBagItem.from_hash(enc_raw_hash) }
|
97
97
|
# If the data bag is encrypted, it gets passed to `edit` as a hash. Otherwise, it gets passed as a DataBag
|
98
|
-
let
|
98
|
+
let(:data_to_edit) { raw_hash }
|
99
99
|
|
100
100
|
before(:each) do
|
101
101
|
expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(true)
|
data/spec/unit/lwrp_spec.rb
CHANGED
@@ -653,14 +653,17 @@ describe "LWRP" do
|
|
653
653
|
end
|
654
654
|
end
|
655
655
|
|
656
|
-
let(:
|
656
|
+
let(:run_context) do
|
657
657
|
cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
|
658
658
|
cookbook_loader = Chef::CookbookLoader.new(cookbook_repo)
|
659
659
|
cookbook_loader.load_cookbooks
|
660
660
|
cookbook_collection = Chef::CookbookCollection.new(cookbook_loader)
|
661
661
|
node = Chef::Node.new
|
662
662
|
events = Chef::EventDispatch::Dispatcher.new
|
663
|
-
|
663
|
+
Chef::RunContext.new(node, cookbook_collection, events)
|
664
|
+
end
|
665
|
+
|
666
|
+
let(:recipe) do
|
664
667
|
Chef::Recipe.new("hjk", "test", run_context)
|
665
668
|
end
|
666
669
|
|
@@ -30,8 +30,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
|
|
30
30
|
it "runs a command and returns the shell_out object" do
|
31
31
|
ret = double("Mixlib::ShellOut")
|
32
32
|
expect(object).to receive(:shell_out).with(
|
33
|
-
"powershell.exe #{flags} -Command \"Get-Process\""
|
34
|
-
{}
|
33
|
+
"powershell.exe #{flags} -Command \"Get-Process\""
|
35
34
|
).and_return(ret)
|
36
35
|
expect(object.powershell_out("Get-Process")).to eql(ret)
|
37
36
|
end
|
@@ -62,8 +61,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
|
|
62
61
|
it "runs a command and returns the shell_out object" do
|
63
62
|
mixlib_shellout = double("Mixlib::ShellOut")
|
64
63
|
expect(object).to receive(:shell_out).with(
|
65
|
-
"powershell.exe #{flags} -Command \"Get-Process\""
|
66
|
-
{}
|
64
|
+
"powershell.exe #{flags} -Command \"Get-Process\""
|
67
65
|
).and_return(mixlib_shellout)
|
68
66
|
expect(mixlib_shellout).to receive(:error!)
|
69
67
|
expect(object.powershell_out!("Get-Process")).to eql(mixlib_shellout)
|
@@ -31,9 +31,9 @@ class ChildWithoutDirective < SubclassDirectiveParent
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe Chef::Mixin::Uris do
|
34
|
-
let
|
34
|
+
let(:child) { SubclassDirectiveChild.new }
|
35
35
|
|
36
|
-
let
|
36
|
+
let(:other_child) { ChildWithoutDirective.new }
|
37
37
|
|
38
38
|
it "the child instance has the directive set" do
|
39
39
|
expect(child.behave_differently?).to be true
|
@@ -27,8 +27,8 @@ class Chef::UnformatterTest
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe Chef::Mixin::Unformatter do
|
30
|
-
let
|
31
|
-
let
|
30
|
+
let(:unformatter) { Chef::UnformatterTest.new }
|
31
|
+
let(:message) { "Test Message" }
|
32
32
|
|
33
33
|
describe "#write" do
|
34
34
|
context "with a timestamp" do
|
@@ -20,15 +20,21 @@ require "chef"
|
|
20
20
|
require "spec_helper"
|
21
21
|
|
22
22
|
describe Chef::Provider::DscResource do
|
23
|
-
let
|
24
|
-
let
|
25
|
-
let
|
26
|
-
let
|
23
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
24
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
25
|
+
let(:resource) { Chef::Resource::DscResource.new("dscresource", run_context) }
|
26
|
+
let(:provider) do
|
27
27
|
Chef::Provider::DscResource.new(resource, run_context)
|
28
28
|
end
|
29
29
|
|
30
|
+
let(:node) do
|
31
|
+
node = Chef::Node.new
|
32
|
+
node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
|
33
|
+
node
|
34
|
+
end
|
35
|
+
|
30
36
|
context "when PowerShell does not support Invoke-DscResource" do
|
31
|
-
let
|
37
|
+
let(:node) do
|
32
38
|
node = Chef::Node.new
|
33
39
|
node.automatic[:languages][:powershell][:version] = "4.0"
|
34
40
|
node
|
@@ -45,7 +51,7 @@ describe Chef::Provider::DscResource do
|
|
45
51
|
|
46
52
|
context "when RefreshMode is not set to Disabled" do
|
47
53
|
context "and the WMF 5 is a preview release" do
|
48
|
-
let
|
54
|
+
let(:node) do
|
49
55
|
node = Chef::Node.new
|
50
56
|
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
|
51
57
|
node
|
@@ -58,7 +64,7 @@ describe Chef::Provider::DscResource do
|
|
58
64
|
end
|
59
65
|
end
|
60
66
|
context "and the WMF is 5 RTM or newer" do
|
61
|
-
let
|
67
|
+
let(:node) do
|
62
68
|
node = Chef::Node.new
|
63
69
|
node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
|
64
70
|
node
|
@@ -74,15 +80,15 @@ describe Chef::Provider::DscResource do
|
|
74
80
|
end
|
75
81
|
|
76
82
|
context "when the LCM supports Invoke-DscResource" do
|
77
|
-
let
|
83
|
+
let(:node) do
|
78
84
|
node = Chef::Node.new
|
79
85
|
node.automatic[:languages][:powershell][:version] = "5.0.10018.0"
|
80
86
|
node
|
81
87
|
end
|
82
|
-
let
|
83
|
-
let
|
84
|
-
let
|
85
|
-
let
|
88
|
+
let(:resource_result) { double("CmdletResult", return_value: { "InDesiredState" => true }, stream: "description") }
|
89
|
+
let(:invoke_dsc_resource) { double("cmdlet", run!: resource_result) }
|
90
|
+
let(:store) { double("ResourceStore", find: resource_records) }
|
91
|
+
let(:resource_records) { [] }
|
86
92
|
|
87
93
|
before do
|
88
94
|
allow(Chef::Util::DSC::ResourceStore).to receive(:instance).and_return(store)
|
@@ -124,7 +130,7 @@ describe Chef::Provider::DscResource do
|
|
124
130
|
end
|
125
131
|
|
126
132
|
context "resource name cannot be found" do
|
127
|
-
let
|
133
|
+
let(:resource_records) { [] }
|
128
134
|
|
129
135
|
it "raises ResourceNotFound" do
|
130
136
|
expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::ResourceNotFound)
|
@@ -133,7 +139,7 @@ describe Chef::Provider::DscResource do
|
|
133
139
|
|
134
140
|
context "resource name is found" do
|
135
141
|
context "no module name for resource found" do
|
136
|
-
let
|
142
|
+
let(:resource_records) { [{}] }
|
137
143
|
|
138
144
|
it "returns the default dsc resource module" do
|
139
145
|
expect(Chef::Util::Powershell::Cmdlet).to receive(:new) do |node, cmdlet, format|
|
@@ -144,7 +150,7 @@ describe Chef::Provider::DscResource do
|
|
144
150
|
end
|
145
151
|
|
146
152
|
context "a module name for resource is found" do
|
147
|
-
let
|
153
|
+
let(:resource_records) { [{ "Module" => { "Name" => "ModuleName" } }] }
|
148
154
|
|
149
155
|
it "returns the default dsc resource module" do
|
150
156
|
expect(Chef::Util::Powershell::Cmdlet).to receive(:new) do |node, cmdlet, format|
|
@@ -155,7 +161,7 @@ describe Chef::Provider::DscResource do
|
|
155
161
|
end
|
156
162
|
|
157
163
|
context "multiple resource are found" do
|
158
|
-
let
|
164
|
+
let(:resource_records) do
|
159
165
|
[
|
160
166
|
{ "Module" => { "Name" => "ModuleName1", "Version" => "1.0.0.0" } },
|
161
167
|
{ "Module" => { "Name" => "ModuleName1", "Version" => "2.0.0.0" } },
|
@@ -170,10 +176,6 @@ describe Chef::Provider::DscResource do
|
|
170
176
|
end
|
171
177
|
|
172
178
|
describe "define_resource_requirements" do
|
173
|
-
let (:node) do
|
174
|
-
set_node_object
|
175
|
-
end
|
176
|
-
|
177
179
|
context "module usage is valid" do
|
178
180
|
before do
|
179
181
|
allow(provider).to receive(:module_usage_valid?).and_return(true)
|
@@ -208,10 +210,6 @@ describe Chef::Provider::DscResource do
|
|
208
210
|
end
|
209
211
|
|
210
212
|
describe "module_usage_valid?" do
|
211
|
-
let (:node) do
|
212
|
-
set_node_object
|
213
|
-
end
|
214
|
-
|
215
213
|
context "module_name and module_version both are not provided" do
|
216
214
|
before do
|
217
215
|
provider.instance_variable_set(:@module_name, nil)
|
@@ -262,10 +260,6 @@ describe Chef::Provider::DscResource do
|
|
262
260
|
end
|
263
261
|
|
264
262
|
describe "module_info_object" do
|
265
|
-
let (:node) do
|
266
|
-
set_node_object
|
267
|
-
end
|
268
|
-
|
269
263
|
context "module_version is not given" do
|
270
264
|
before do
|
271
265
|
provider.instance_variable_set(:@module_version, nil)
|
@@ -292,10 +286,6 @@ describe Chef::Provider::DscResource do
|
|
292
286
|
end
|
293
287
|
|
294
288
|
describe "invoke_resource" do
|
295
|
-
let (:node) do
|
296
|
-
set_node_object
|
297
|
-
end
|
298
|
-
|
299
289
|
let(:cmdlet) { double(run!: nil) }
|
300
290
|
|
301
291
|
before(:each) do
|
@@ -338,9 +328,3 @@ describe Chef::Provider::DscResource do
|
|
338
328
|
end
|
339
329
|
end
|
340
330
|
end
|
341
|
-
|
342
|
-
def set_node_object
|
343
|
-
node = Chef::Node.new
|
344
|
-
node.automatic[:languages][:powershell][:version] = "5.0.10586.0"
|
345
|
-
node
|
346
|
-
end
|
@@ -23,15 +23,15 @@ require "spec_helper"
|
|
23
23
|
|
24
24
|
describe Chef::Provider::DscScript do
|
25
25
|
context "when DSC is available" do
|
26
|
-
let
|
26
|
+
let(:node) do
|
27
27
|
node = Chef::Node.new
|
28
28
|
node.automatic[:languages][:powershell][:version] = "4.0"
|
29
29
|
node
|
30
30
|
end
|
31
|
-
let
|
32
|
-
let
|
33
|
-
let
|
34
|
-
let
|
31
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
32
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
33
|
+
let(:resource) { Chef::Resource::DscScript.new("script", run_context) }
|
34
|
+
let(:provider) do
|
35
35
|
Chef::Provider::DscScript.new(resource, run_context)
|
36
36
|
end
|
37
37
|
|
@@ -145,11 +145,11 @@ describe Chef::Provider::DscScript do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
context "when Dsc is not available" do
|
148
|
-
let
|
149
|
-
let
|
150
|
-
let
|
151
|
-
let
|
152
|
-
let
|
148
|
+
let(:node) { Chef::Node.new }
|
149
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
150
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
151
|
+
let(:resource) { Chef::Resource::DscScript.new("script", run_context) }
|
152
|
+
let(:provider) { Chef::Provider::DscScript.new(resource, run_context) }
|
153
153
|
|
154
154
|
describe "action_run" do
|
155
155
|
["1.0", "2.0", "3.0"].each do |version|
|
@@ -26,7 +26,7 @@ describe Chef::Provider::Execute do
|
|
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
28
|
# You will be the same object, I promise.
|
29
|
-
@live_stream = Chef::EventDispatch::EventsOutputStream.new(
|
29
|
+
@live_stream = Chef::EventDispatch::EventsOutputStream.new(Chef::EventDispatch::Dispatcher.new, name: :execute)
|
30
30
|
|
31
31
|
let(:opts) do
|
32
32
|
{
|
@@ -293,7 +293,7 @@ describe Chef::Provider::Git do
|
|
293
293
|
end
|
294
294
|
end
|
295
295
|
context "with a timeout set" do
|
296
|
-
let
|
296
|
+
let(:seconds) { 10 }
|
297
297
|
before { @resource.timeout(seconds) }
|
298
298
|
it "clones a repo with amended git options" do
|
299
299
|
expect(@provider).to receive(:shell_out!).with(expected_cmd, default_options.merge(timeout: seconds))
|
@@ -301,7 +301,7 @@ describe Chef::Provider::Git do
|
|
301
301
|
end
|
302
302
|
end
|
303
303
|
context "with a specific home" do
|
304
|
-
let
|
304
|
+
let(:override_home) do
|
305
305
|
{ "HOME" => "/home/masterNinja" }
|
306
306
|
end
|
307
307
|
let(:overrided_options) do
|
@@ -337,7 +337,7 @@ describe Chef::Provider::Git do
|
|
337
337
|
allow(Etc).to receive(:getpwuid).and_return(double("Struct::Passwd", name: @resource.user, dir: "/home/deployNinja"))
|
338
338
|
end
|
339
339
|
context "with a specific home" do
|
340
|
-
let
|
340
|
+
let(:override_home) do
|
341
341
|
{ "HOME" => "/home/masterNinja" }
|
342
342
|
end
|
343
343
|
let(:overrided_options) do
|
@@ -22,9 +22,7 @@ require "ostruct"
|
|
22
22
|
describe Chef::Resource::Mdadm do
|
23
23
|
|
24
24
|
before(:each) do
|
25
|
-
|
26
|
-
@events = Chef::EventDispatch::Dispatcher.new
|
27
|
-
@run_context = Chef::RunContext.new(@node, {}, @events)
|
25
|
+
run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
|
28
26
|
@new_resource = Chef::Resource::Mdadm.new("/dev/md1", run_context)
|
29
27
|
@new_resource.devices ["/dev/sdz1", "/dev/sdz2", "/dev/sdz3"]
|
30
28
|
@provider = @new_resource.provider_for_action(:create)
|
@@ -27,7 +27,7 @@ describe Chef::Provider::Package::Openbsd do
|
|
27
27
|
node
|
28
28
|
end
|
29
29
|
|
30
|
-
let
|
30
|
+
let(:provider) do
|
31
31
|
events = Chef::EventDispatch::Dispatcher.new
|
32
32
|
run_context = Chef::RunContext.new(node, {}, events)
|
33
33
|
Chef::Provider::Package::Openbsd.new(new_resource, run_context)
|
@@ -17,13 +17,6 @@
|
|
17
17
|
#
|
18
18
|
require "spec_helper"
|
19
19
|
|
20
|
-
def create_provider_for(name)
|
21
|
-
@new_resource = Chef::Resource::Package.new(name)
|
22
|
-
provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context)
|
23
|
-
allow(provider).to receive(:shell_out_compacted).and_return(@status)
|
24
|
-
provider
|
25
|
-
end
|
26
|
-
|
27
20
|
RSpec.shared_examples "current_resource" do |pkg, version, candidate|
|
28
21
|
let(:current_resource) { @provider.load_current_resource }
|
29
22
|
before(:each) do
|
@@ -45,11 +38,23 @@ RSpec.shared_examples "current_resource" do |pkg, version, candidate|
|
|
45
38
|
end
|
46
39
|
|
47
40
|
describe Chef::Provider::Package::Pacman do
|
41
|
+
def create_provider_for(name)
|
42
|
+
new_resource = Chef::Resource::Package.new(name)
|
43
|
+
run_context = Chef::RunContext.new(Chef::Node.new, {}, Chef::EventDispatch::Dispatcher.new)
|
44
|
+
provider = Chef::Provider::Package::Pacman.new(new_resource, run_context)
|
45
|
+
|
46
|
+
pacman_out = <<~PACMAN_OUT
|
47
|
+
extra nano 3.450-1
|
48
|
+
extra emacs 0.12.0-1 [installed]
|
49
|
+
core sed 3.234-2 [installed: 3.234-1]
|
50
|
+
PACMAN_OUT
|
51
|
+
|
52
|
+
allow(provider).to receive(:shell_out_compacted).and_return(double(stdout: pacman_out, exitstatus: 0))
|
53
|
+
provider
|
54
|
+
end
|
55
|
+
|
48
56
|
before(:each) do
|
49
|
-
|
50
|
-
@events = Chef::EventDispatch::Dispatcher.new
|
51
|
-
@run_context = Chef::RunContext.new(@node, {}, @events)
|
52
|
-
@pacman_conf = <<~PACMAN_CONF
|
57
|
+
pacman_conf = <<~PACMAN_CONF
|
53
58
|
[options]
|
54
59
|
HoldPkg = pacman glibc
|
55
60
|
Architecture = auto
|
@@ -68,15 +73,7 @@ describe Chef::Provider::Package::Pacman do
|
|
68
73
|
PACMAN_CONF
|
69
74
|
|
70
75
|
allow(::File).to receive(:exist?).with("/etc/pacman.conf").and_return(true)
|
71
|
-
allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(
|
72
|
-
|
73
|
-
pacman_out = <<~PACMAN_OUT
|
74
|
-
extra nano 3.450-1
|
75
|
-
extra emacs 0.12.0-1 [installed]
|
76
|
-
core sed 3.234-2 [installed: 3.234-1]
|
77
|
-
PACMAN_OUT
|
78
|
-
@status = double(stdout: pacman_out, exitstatus: 0)
|
79
|
-
|
76
|
+
allow(::File).to receive(:read).with("/etc/pacman.conf").and_return(pacman_conf)
|
80
77
|
end
|
81
78
|
|
82
79
|
describe "loading the current resource" do
|