chef 12.0.1 → 12.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -1
- data/lib/chef/digester.rb +1 -0
- data/lib/chef/dsl/recipe.rb +2 -1
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/knife.rb +7 -0
- data/lib/chef/knife/cookbook_site_install.rb +34 -10
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/package/apt.rb +2 -2
- data/lib/chef/provider/package/homebrew.rb +11 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -0
- data/lib/chef/provider/subversion.rb +3 -3
- data/lib/chef/resource.rb +23 -91
- data/lib/chef/resource/homebrew_package.rb +2 -1
- data/lib/chef/resource/resource_notification.rb +109 -0
- data/lib/chef/resource_collection/resource_set.rb +8 -8
- data/lib/chef/run_context.rb +4 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/whitelist.rb +3 -1
- data/lib/chef/win32/api/file.rb +17 -3
- data/spec/functional/notifications_spec.rb +169 -0
- data/spec/functional/resource/link_spec.rb +31 -32
- data/spec/support/platform_helpers.rb +5 -2
- data/spec/unit/knife/cookbook_site_install_spec.rb +157 -116
- data/spec/unit/knife_spec.rb +108 -78
- data/spec/unit/mixin/shell_out_spec.rb +39 -40
- data/spec/unit/node_spec.rb +34 -0
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/apt_spec.rb +264 -257
- data/spec/unit/provider/package/homebrew_spec.rb +26 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +18 -3
- data/spec/unit/provider/subversion_spec.rb +5 -5
- data/spec/unit/provider_resolver_spec.rb +2 -2
- data/spec/unit/recipe_spec.rb +1 -0
- data/spec/unit/resource/apt_package_spec.rb +3 -5
- data/spec/unit/resource/resource_notification_spec.rb +170 -0
- data/spec/unit/resource_spec.rb +0 -151
- data/spec/unit/run_context_spec.rb +94 -55
- metadata +5 -2
@@ -93,6 +93,27 @@ describe Chef::Provider::Package::Homebrew do
|
|
93
93
|
}
|
94
94
|
end
|
95
95
|
|
96
|
+
let(:keg_only_uninstalled_brew_info) do
|
97
|
+
{
|
98
|
+
'name' => 'emacs-kegger',
|
99
|
+
'homepage' => 'http://www.gnu.org/software/emacs/',
|
100
|
+
'versions' => {
|
101
|
+
'stable' => '24.3-keggy',
|
102
|
+
'bottle' => false,
|
103
|
+
'devel' => nil,
|
104
|
+
'head' => 'HEAD'
|
105
|
+
},
|
106
|
+
'revision' => 0,
|
107
|
+
'installed' => [],
|
108
|
+
'linked_keg' => nil,
|
109
|
+
'keg_only' => true,
|
110
|
+
'dependencies' => [],
|
111
|
+
'conflicts_with' => [],
|
112
|
+
'caveats' => '',
|
113
|
+
'options' => []
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
96
117
|
before(:each) do
|
97
118
|
|
98
119
|
end
|
@@ -141,6 +162,11 @@ describe Chef::Provider::Package::Homebrew do
|
|
141
162
|
allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info)
|
142
163
|
expect(provider.current_installed_version).to be_nil
|
143
164
|
end
|
165
|
+
|
166
|
+
it 'returns nil if the package is keg only and not installed' do
|
167
|
+
allow(provider).to receive(:brew_info).and_return(keg_only_uninstalled_brew_info)
|
168
|
+
expect(provider.current_installed_version).to be_nil
|
169
|
+
end
|
144
170
|
end
|
145
171
|
|
146
172
|
describe 'brew' do
|
@@ -18,13 +18,22 @@
|
|
18
18
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
|
-
describe Chef::Provider::Package::Windows::MSI
|
21
|
+
describe Chef::Provider::Package::Windows::MSI do
|
22
22
|
let(:node) { double('Chef::Node') }
|
23
23
|
let(:events) { double('Chef::Events').as_null_object } # mock all the methods
|
24
24
|
let(:run_context) { double('Chef::RunContext', :node => node, :events => events) }
|
25
25
|
let(:new_resource) { Chef::Resource::WindowsPackage.new("calculator.msi") }
|
26
26
|
let(:provider) { Chef::Provider::Package::Windows::MSI.new(new_resource) }
|
27
27
|
|
28
|
+
before(:each) do
|
29
|
+
stub_const("File::ALT_SEPARATOR", "\\")
|
30
|
+
allow(::File).to receive(:absolute_path).with("calculator.msi").and_return("calculator.msi")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "responds to shell_out!" do
|
34
|
+
expect(provider).to respond_to(:shell_out!)
|
35
|
+
end
|
36
|
+
|
28
37
|
describe "expand_options" do
|
29
38
|
it "returns an empty string if passed no options" do
|
30
39
|
expect(provider.expand_options(nil)).to eql ""
|
@@ -51,10 +60,16 @@ describe Chef::Provider::Package::Windows::MSI, :windows_only do
|
|
51
60
|
end
|
52
61
|
|
53
62
|
describe "install_package" do
|
54
|
-
|
63
|
+
it "calls msiexec /qn /i" do
|
64
|
+
expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/i \"calculator.msi\"/, kind_of(Hash))
|
65
|
+
provider.install_package("unused", "unused")
|
66
|
+
end
|
55
67
|
end
|
56
68
|
|
57
69
|
describe "remove_package" do
|
58
|
-
|
70
|
+
it "calls msiexec /qn /x" do
|
71
|
+
expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/x \"calculator.msi\"/, kind_of(Hash))
|
72
|
+
provider.remove_package("unused", "unused")
|
73
|
+
end
|
59
74
|
end
|
60
75
|
end
|
@@ -198,7 +198,7 @@ describe Chef::Provider::Subversion do
|
|
198
198
|
it "runs an export with the --force option" do
|
199
199
|
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
|
200
200
|
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
201
|
-
expect(@provider).to receive(:shell_out!).with(
|
201
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd, {})
|
202
202
|
@provider.run_action(:force_export)
|
203
203
|
expect(@resource).to be_updated
|
204
204
|
end
|
@@ -206,7 +206,7 @@ describe Chef::Provider::Subversion do
|
|
206
206
|
it "runs the checkout command for action_checkout" do
|
207
207
|
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
|
208
208
|
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
209
|
-
expect(@provider).to receive(:shell_out!).with(
|
209
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd, {})
|
210
210
|
@provider.run_action(:checkout)
|
211
211
|
expect(@resource).to be_updated
|
212
212
|
end
|
@@ -230,7 +230,7 @@ describe Chef::Provider::Subversion do
|
|
230
230
|
@resource.user "whois"
|
231
231
|
@resource.group "thisis"
|
232
232
|
expected_cmd = "svn checkout -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
233
|
-
expect(@provider).to receive(:shell_out!).with(
|
233
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd, {user: "whois", group: "thisis"})
|
234
234
|
@provider.run_action(:checkout)
|
235
235
|
expect(@resource).to be_updated
|
236
236
|
end
|
@@ -255,7 +255,7 @@ describe Chef::Provider::Subversion do
|
|
255
255
|
allow(@provider).to receive(:find_current_revision).and_return("11410")
|
256
256
|
allow(@provider).to receive(:current_revision_matches_target_revision?).and_return(false)
|
257
257
|
expected_cmd = "svn update -q -r12345 /my/deploy/dir"
|
258
|
-
expect(@provider).to receive(:shell_out!).with(
|
258
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd, {})
|
259
259
|
@provider.run_action(:sync)
|
260
260
|
expect(@resource).to be_updated
|
261
261
|
end
|
@@ -272,7 +272,7 @@ describe Chef::Provider::Subversion do
|
|
272
272
|
it "runs the export_command on action_export" do
|
273
273
|
allow(::File).to receive(:directory?).with("/my/deploy").and_return(true)
|
274
274
|
expected_cmd = "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir"
|
275
|
-
expect(@provider).to receive(:shell_out!).with(
|
275
|
+
expect(@provider).to receive(:shell_out!).with(expected_cmd, {})
|
276
276
|
@provider.run_action(:export)
|
277
277
|
expect(@resource).to be_updated
|
278
278
|
end
|
@@ -514,7 +514,7 @@ describe Chef::ProviderResolver do
|
|
514
514
|
:deploy_revision, :directory, :dpkg_package, :easy_install_package,
|
515
515
|
:erl_call, :execute, :file, :gem_package, :git, :http_request, :link, :log, :pacman_package, :paludis_package,
|
516
516
|
:perl, :python, :remote_directory, :route, :rpm_package, :ruby, :ruby_block, :script,
|
517
|
-
:subversion, :template, :timestamped_deploy, :whyrun_safe_ruby_block, :yum_package,
|
517
|
+
:subversion, :template, :timestamped_deploy, :whyrun_safe_ruby_block, :yum_package, :homebrew_package,
|
518
518
|
]
|
519
519
|
|
520
520
|
supported_providers.each do |static_resource|
|
@@ -530,7 +530,7 @@ describe Chef::ProviderResolver do
|
|
530
530
|
end
|
531
531
|
|
532
532
|
unsupported_providers = [
|
533
|
-
:bff_package, :dsc_script, :
|
533
|
+
:bff_package, :dsc_script, :ips_package, :macports_package,
|
534
534
|
:smartos_package, :solaris_package, :windows_package,
|
535
535
|
:windows_service,
|
536
536
|
]
|
data/spec/unit/recipe_spec.rb
CHANGED
@@ -154,6 +154,7 @@ describe Chef::Recipe do
|
|
154
154
|
zm_resource.recipe_name.should == "test"
|
155
155
|
zm_resource.cookbook_name.should == "hjk"
|
156
156
|
zm_resource.source_line.should include(__FILE__)
|
157
|
+
zm_resource.declared_type.should == :zen_master
|
157
158
|
end
|
158
159
|
|
159
160
|
it "does not add the resource to the resource collection" do
|
@@ -29,12 +29,10 @@ describe Chef::Resource::AptPackage, "initialize" do
|
|
29
29
|
os: "linux",
|
30
30
|
)
|
31
31
|
|
32
|
-
|
33
|
-
@resource = Chef::Resource::AptPackage.new("foo")
|
34
|
-
end
|
32
|
+
let(:resource) { Chef::Resource::AptPackage.new("foo") }
|
35
33
|
|
36
34
|
it "should support default_release" do
|
37
|
-
|
38
|
-
expect(
|
35
|
+
resource.default_release("lenny-backports")
|
36
|
+
expect(resource.default_release).to eql("lenny-backports")
|
39
37
|
end
|
40
38
|
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tyler Ball (<tball@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
require 'spec_helper'
|
19
|
+
require 'chef/resource/resource_notification'
|
20
|
+
|
21
|
+
describe Chef::Resource::Notification do
|
22
|
+
before do
|
23
|
+
@notification = Chef::Resource::Notification.new(:service_apache, :restart, :template_httpd_conf)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has a resource to be notified" do
|
27
|
+
@notification.resource.should == :service_apache
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has an action to take on the service" do
|
31
|
+
@notification.action.should == :restart
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has a notifying resource" do
|
35
|
+
@notification.notifying_resource.should == :template_httpd_conf
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is a duplicate of another notification with the same target resource and action" do
|
39
|
+
other = Chef::Resource::Notification.new(:service_apache, :restart, :sync_web_app_code)
|
40
|
+
@notification.duplicates?(other).should be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "is not a duplicate of another notification if the actions differ" do
|
44
|
+
other = Chef::Resource::Notification.new(:service_apache, :enable, :install_apache)
|
45
|
+
@notification.duplicates?(other).should be_false
|
46
|
+
end
|
47
|
+
|
48
|
+
it "is not a duplicate of another notification if the target resources differ" do
|
49
|
+
other = Chef::Resource::Notification.new(:service_sshd, :restart, :template_httpd_conf)
|
50
|
+
@notification.duplicates?(other).should be_false
|
51
|
+
end
|
52
|
+
|
53
|
+
it "raises an ArgumentError if you try to check a non-ducktype object for duplication" do
|
54
|
+
lambda {@notification.duplicates?(:not_a_notification)}.should raise_error(ArgumentError)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "takes no action to resolve a resource reference that doesn't need to be resolved" do
|
58
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
59
|
+
@notification.resource = @keyboard_cat
|
60
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
61
|
+
@notification.notifying_resource = @long_cat
|
62
|
+
@resource_collection = Chef::ResourceCollection.new
|
63
|
+
# would raise an error since the resource is not in the collection
|
64
|
+
@notification.resolve_resource_reference(@resource_collection)
|
65
|
+
@notification.resource.should == @keyboard_cat
|
66
|
+
end
|
67
|
+
|
68
|
+
it "resolves a lazy reference to a resource" do
|
69
|
+
@notification.resource = {:cat => "keyboard_cat"}
|
70
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
71
|
+
@resource_collection = Chef::ResourceCollection.new
|
72
|
+
@resource_collection << @keyboard_cat
|
73
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
74
|
+
@notification.notifying_resource = @long_cat
|
75
|
+
@notification.resolve_resource_reference(@resource_collection)
|
76
|
+
@notification.resource.should == @keyboard_cat
|
77
|
+
end
|
78
|
+
|
79
|
+
it "resolves a lazy reference to its notifying resource" do
|
80
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
81
|
+
@notification.resource = @keyboard_cat
|
82
|
+
@notification.notifying_resource = {:cat => "long_cat"}
|
83
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
84
|
+
@resource_collection = Chef::ResourceCollection.new
|
85
|
+
@resource_collection << @long_cat
|
86
|
+
@notification.resolve_resource_reference(@resource_collection)
|
87
|
+
@notification.notifying_resource.should == @long_cat
|
88
|
+
end
|
89
|
+
|
90
|
+
it "resolves lazy references to both its resource and its notifying resource" do
|
91
|
+
@notification.resource = {:cat => "keyboard_cat"}
|
92
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
93
|
+
@resource_collection = Chef::ResourceCollection.new
|
94
|
+
@resource_collection << @keyboard_cat
|
95
|
+
@notification.notifying_resource = {:cat => "long_cat"}
|
96
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
97
|
+
@resource_collection << @long_cat
|
98
|
+
@notification.resolve_resource_reference(@resource_collection)
|
99
|
+
@notification.resource.should == @keyboard_cat
|
100
|
+
@notification.notifying_resource.should == @long_cat
|
101
|
+
end
|
102
|
+
|
103
|
+
it "raises a RuntimeError if you try to reference multiple resources" do
|
104
|
+
@notification.resource = {:cat => ["keyboard_cat", "cheez_cat"]}
|
105
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
106
|
+
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
107
|
+
@resource_collection = Chef::ResourceCollection.new
|
108
|
+
@resource_collection << @keyboard_cat
|
109
|
+
@resource_collection << @cheez_cat
|
110
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
111
|
+
@notification.notifying_resource = @long_cat
|
112
|
+
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "raises a RuntimeError if you try to reference multiple notifying resources" do
|
116
|
+
@notification.notifying_resource = {:cat => ["long_cat", "cheez_cat"]}
|
117
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
118
|
+
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
119
|
+
@resource_collection = Chef::ResourceCollection.new
|
120
|
+
@resource_collection << @long_cat
|
121
|
+
@resource_collection << @cheez_cat
|
122
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
123
|
+
@notification.resource = @keyboard_cat
|
124
|
+
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "raises a RuntimeError if it can't find a resource in the resource collection when resolving a lazy reference" do
|
128
|
+
@notification.resource = {:cat => "keyboard_cat"}
|
129
|
+
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
130
|
+
@resource_collection = Chef::ResourceCollection.new
|
131
|
+
@resource_collection << @cheez_cat
|
132
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
133
|
+
@notification.notifying_resource = @long_cat
|
134
|
+
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
135
|
+
end
|
136
|
+
|
137
|
+
it "raises a RuntimeError if it can't find a notifying resource in the resource collection when resolving a lazy reference" do
|
138
|
+
@notification.notifying_resource = {:cat => "long_cat"}
|
139
|
+
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
140
|
+
@resource_collection = Chef::ResourceCollection.new
|
141
|
+
@resource_collection << @cheez_cat
|
142
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
143
|
+
@notification.resource = @keyboard_cat
|
144
|
+
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "raises an ArgumentError if improper syntax is used in the lazy reference to its resource" do
|
148
|
+
@notification.resource = "cat => keyboard_cat"
|
149
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
150
|
+
@resource_collection = Chef::ResourceCollection.new
|
151
|
+
@resource_collection << @keyboard_cat
|
152
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
153
|
+
@notification.notifying_resource = @long_cat
|
154
|
+
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(ArgumentError)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "raises an ArgumentError if improper syntax is used in the lazy reference to its notifying resource" do
|
158
|
+
@notification.notifying_resource = "cat => long_cat"
|
159
|
+
@long_cat = Chef::Resource::Cat.new("long_cat")
|
160
|
+
@resource_collection = Chef::ResourceCollection.new
|
161
|
+
@resource_collection << @long_cat
|
162
|
+
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
163
|
+
@notification.resource = @keyboard_cat
|
164
|
+
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(ArgumentError)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Create test to resolve lazy references to both notifying resource and dest. resource
|
168
|
+
# Create tests to check proper error raising
|
169
|
+
|
170
|
+
end
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -855,154 +855,3 @@ describe Chef::Resource do
|
|
855
855
|
|
856
856
|
end
|
857
857
|
end
|
858
|
-
|
859
|
-
describe Chef::Resource::Notification do
|
860
|
-
before do
|
861
|
-
@notification = Chef::Resource::Notification.new(:service_apache, :restart, :template_httpd_conf)
|
862
|
-
end
|
863
|
-
|
864
|
-
it "has a resource to be notified" do
|
865
|
-
@notification.resource.should == :service_apache
|
866
|
-
end
|
867
|
-
|
868
|
-
it "has an action to take on the service" do
|
869
|
-
@notification.action.should == :restart
|
870
|
-
end
|
871
|
-
|
872
|
-
it "has a notifying resource" do
|
873
|
-
@notification.notifying_resource.should == :template_httpd_conf
|
874
|
-
end
|
875
|
-
|
876
|
-
it "is a duplicate of another notification with the same target resource and action" do
|
877
|
-
other = Chef::Resource::Notification.new(:service_apache, :restart, :sync_web_app_code)
|
878
|
-
@notification.duplicates?(other).should be_true
|
879
|
-
end
|
880
|
-
|
881
|
-
it "is not a duplicate of another notification if the actions differ" do
|
882
|
-
other = Chef::Resource::Notification.new(:service_apache, :enable, :install_apache)
|
883
|
-
@notification.duplicates?(other).should be_false
|
884
|
-
end
|
885
|
-
|
886
|
-
it "is not a duplicate of another notification if the target resources differ" do
|
887
|
-
other = Chef::Resource::Notification.new(:service_sshd, :restart, :template_httpd_conf)
|
888
|
-
@notification.duplicates?(other).should be_false
|
889
|
-
end
|
890
|
-
|
891
|
-
it "raises an ArgumentError if you try to check a non-ducktype object for duplication" do
|
892
|
-
lambda {@notification.duplicates?(:not_a_notification)}.should raise_error(ArgumentError)
|
893
|
-
end
|
894
|
-
|
895
|
-
it "takes no action to resolve a resource reference that doesn't need to be resolved" do
|
896
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
897
|
-
@notification.resource = @keyboard_cat
|
898
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
899
|
-
@notification.notifying_resource = @long_cat
|
900
|
-
@resource_collection = Chef::ResourceCollection.new
|
901
|
-
# would raise an error since the resource is not in the collection
|
902
|
-
@notification.resolve_resource_reference(@resource_collection)
|
903
|
-
@notification.resource.should == @keyboard_cat
|
904
|
-
end
|
905
|
-
|
906
|
-
it "resolves a lazy reference to a resource" do
|
907
|
-
@notification.resource = {:cat => "keyboard_cat"}
|
908
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
909
|
-
@resource_collection = Chef::ResourceCollection.new
|
910
|
-
@resource_collection << @keyboard_cat
|
911
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
912
|
-
@notification.notifying_resource = @long_cat
|
913
|
-
@notification.resolve_resource_reference(@resource_collection)
|
914
|
-
@notification.resource.should == @keyboard_cat
|
915
|
-
end
|
916
|
-
|
917
|
-
it "resolves a lazy reference to its notifying resource" do
|
918
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
919
|
-
@notification.resource = @keyboard_cat
|
920
|
-
@notification.notifying_resource = {:cat => "long_cat"}
|
921
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
922
|
-
@resource_collection = Chef::ResourceCollection.new
|
923
|
-
@resource_collection << @long_cat
|
924
|
-
@notification.resolve_resource_reference(@resource_collection)
|
925
|
-
@notification.notifying_resource.should == @long_cat
|
926
|
-
end
|
927
|
-
|
928
|
-
it "resolves lazy references to both its resource and its notifying resource" do
|
929
|
-
@notification.resource = {:cat => "keyboard_cat"}
|
930
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
931
|
-
@resource_collection = Chef::ResourceCollection.new
|
932
|
-
@resource_collection << @keyboard_cat
|
933
|
-
@notification.notifying_resource = {:cat => "long_cat"}
|
934
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
935
|
-
@resource_collection << @long_cat
|
936
|
-
@notification.resolve_resource_reference(@resource_collection)
|
937
|
-
@notification.resource.should == @keyboard_cat
|
938
|
-
@notification.notifying_resource.should == @long_cat
|
939
|
-
end
|
940
|
-
|
941
|
-
it "raises a RuntimeError if you try to reference multiple resources" do
|
942
|
-
@notification.resource = {:cat => ["keyboard_cat", "cheez_cat"]}
|
943
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
944
|
-
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
945
|
-
@resource_collection = Chef::ResourceCollection.new
|
946
|
-
@resource_collection << @keyboard_cat
|
947
|
-
@resource_collection << @cheez_cat
|
948
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
949
|
-
@notification.notifying_resource = @long_cat
|
950
|
-
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
951
|
-
end
|
952
|
-
|
953
|
-
it "raises a RuntimeError if you try to reference multiple notifying resources" do
|
954
|
-
@notification.notifying_resource = {:cat => ["long_cat", "cheez_cat"]}
|
955
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
956
|
-
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
957
|
-
@resource_collection = Chef::ResourceCollection.new
|
958
|
-
@resource_collection << @long_cat
|
959
|
-
@resource_collection << @cheez_cat
|
960
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
961
|
-
@notification.resource = @keyboard_cat
|
962
|
-
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
963
|
-
end
|
964
|
-
|
965
|
-
it "raises a RuntimeError if it can't find a resource in the resource collection when resolving a lazy reference" do
|
966
|
-
@notification.resource = {:cat => "keyboard_cat"}
|
967
|
-
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
968
|
-
@resource_collection = Chef::ResourceCollection.new
|
969
|
-
@resource_collection << @cheez_cat
|
970
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
971
|
-
@notification.notifying_resource = @long_cat
|
972
|
-
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
973
|
-
end
|
974
|
-
|
975
|
-
it "raises a RuntimeError if it can't find a notifying resource in the resource collection when resolving a lazy reference" do
|
976
|
-
@notification.notifying_resource = {:cat => "long_cat"}
|
977
|
-
@cheez_cat = Chef::Resource::Cat.new("cheez_cat")
|
978
|
-
@resource_collection = Chef::ResourceCollection.new
|
979
|
-
@resource_collection << @cheez_cat
|
980
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
981
|
-
@notification.resource = @keyboard_cat
|
982
|
-
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(RuntimeError)
|
983
|
-
end
|
984
|
-
|
985
|
-
it "raises an ArgumentError if improper syntax is used in the lazy reference to its resource" do
|
986
|
-
@notification.resource = "cat => keyboard_cat"
|
987
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
988
|
-
@resource_collection = Chef::ResourceCollection.new
|
989
|
-
@resource_collection << @keyboard_cat
|
990
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
991
|
-
@notification.notifying_resource = @long_cat
|
992
|
-
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(ArgumentError)
|
993
|
-
end
|
994
|
-
|
995
|
-
it "raises an ArgumentError if improper syntax is used in the lazy reference to its notifying resource" do
|
996
|
-
@notification.notifying_resource = "cat => long_cat"
|
997
|
-
@long_cat = Chef::Resource::Cat.new("long_cat")
|
998
|
-
@resource_collection = Chef::ResourceCollection.new
|
999
|
-
@resource_collection << @long_cat
|
1000
|
-
@keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
|
1001
|
-
@notification.resource = @keyboard_cat
|
1002
|
-
lambda {@notification.resolve_resource_reference(@resource_collection)}.should raise_error(ArgumentError)
|
1003
|
-
end
|
1004
|
-
|
1005
|
-
# Create test to resolve lazy references to both notifying resource and dest. resource
|
1006
|
-
# Create tests to check proper error raising
|
1007
|
-
|
1008
|
-
end
|