summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2021-05-04 18:42:32 -0700
committerGitHub <noreply@github.com>2021-05-04 18:42:32 -0700
commite4e220838c215ad3a48341bba7c8121bdd5e43a9 (patch)
treefc767849d8c53ff2db4fab939033d9dba4655951 /spec
parentdc449c3accd6aef162b90206e6a2b8650dea3550 (diff)
parentfce4270147d788820f7b8902ea38f7332f7b7554 (diff)
downloadchef-e4e220838c215ad3a48341bba7c8121bdd5e43a9.tar.gz
Merge pull request #11519 from chef/lcg/edit-resource-unified-mode-fix
Fix edit_resource usage in unified_mode
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/recipes/unified_mode_spec.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/integration/recipes/unified_mode_spec.rb b/spec/integration/recipes/unified_mode_spec.rb
index 38ee52511d..d79d534490 100644
--- a/spec/integration/recipes/unified_mode_spec.rb
+++ b/spec/integration/recipes/unified_mode_spec.rb
@@ -874,4 +874,74 @@ describe "Unified Mode" do
result.error!
end
end
+
+ when_the_repository "has a resource that uses edit_resource to create a subresource" do
+ before do
+ directory "cookbooks/x" do
+ file "recipes/default.rb", <<~EOM
+ my_resource "doit"
+ EOM
+
+ file "resources/my_resource.rb", <<~EOM
+ unified_mode true
+ provides :my_resource
+
+ action :doit do
+ edit_resource(:log, "name") do
+ message "GOOD"
+ level :warn
+ end
+ end
+ EOM
+ end
+ end
+
+ it "recipes should still have a compile/converge mode" do
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to("cookbooks")}"
+ log_level :warn
+ EOM
+
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ # in recipe mode we should still run normally with a compile/converge mode
+ expect(result.stdout).to include("GOOD")
+ result.error!
+ end
+ end
+
+ when_the_repository "has a resource that uses find_resource to create a subresource" do
+ before do
+ directory "cookbooks/x" do
+ file "recipes/default.rb", <<~EOM
+ my_resource "doit"
+ EOM
+
+ file "resources/my_resource.rb", <<~EOM
+ unified_mode true
+ provides :my_resource
+
+ action :doit do
+ find_resource(:log, "name") do
+ message "GOOD"
+ level :warn
+ end
+ end
+ EOM
+ end
+ end
+
+ it "recipes should still have a compile/converge mode" do
+ file "config/client.rb", <<~EOM
+ local_mode true
+ cookbook_path "#{path_to("cookbooks")}"
+ log_level :warn
+ EOM
+
+ result = shell_out("#{chef_client} -c \"#{path_to("config/client.rb")}\" --no-color -F doc -o 'x::default'", cwd: chef_dir)
+ # in recipe mode we should still run normally with a compile/converge mode
+ expect(result.stdout).to include("GOOD")
+ result.error!
+ end
+ end
end