diff options
author | Thom May <thom@chef.io> | 2017-04-18 16:29:44 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2017-04-19 15:03:45 +0100 |
commit | 2f5e8b49c260ae0a578187b1d267697b6e391404 (patch) | |
tree | 1b00396448cc07059010f536369e12b64a2c4b8a | |
parent | b2c19a070a3886229b123022ed1636a214df0ae6 (diff) | |
download | chef-2f5e8b49c260ae0a578187b1d267697b6e391404.tar.gz |
Add tests for lazy load of cookbook files
Signed-off-by: Thom May <thom@may.lt>
-rw-r--r-- | spec/integration/client/client_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 00086c75ca..f425144b52 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -306,6 +306,7 @@ local_mode true cookbook_path "#{path_to('cookbooks')}" EOM result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", :cwd => chef_dir) + result.error! expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be true end @@ -315,6 +316,7 @@ local_mode true cookbook_path "#{path_to('cookbooks')}" EOM result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir) + result.error! expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be false end end @@ -464,6 +466,37 @@ end end end + when_the_repository "has a cookbook that deploys a file" do + before do + file "cookbooks/x/recipes/default.rb", <<-RECIPE +cookbook_file #{path_to('tempfile.txt').inspect} do + source "my_file" +end + RECIPE + + file "cookbooks/x/files/my_file", <<-FILE +this is my file + FILE + end + + [true, false].each do |lazy| + context "with no_lazy_load set to #{lazy}" do + it "should run the ohai plugin" do + file "config/client.rb", <<EOM +no_lazy_load #{lazy} +local_mode true +cookbook_path "#{path_to('cookbooks')}" +EOM + result = shell_out("#{chef_client} -l debug -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir) + result.error! + + expect(IO.read(path_to("tempfile.txt")).strip).to eq("this is my file") + end + end + end + end + + when_the_repository "has a cookbook with an ohai plugin" do before do file "cookbooks/x/recipes/default.rb", <<-RECIPE |