diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-04-15 14:56:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-15 14:56:55 -0700 |
commit | 890e090e74eb435b8ed04b61a6a41f4649f4b9ab (patch) | |
tree | ee86ab4a949e128c1aa7482c18228aec4469e27c /spec | |
parent | 2fe2f5029df438ff92274b3240df5f5bee10c067 (diff) | |
parent | 6607b130fe16fa9f28300548d01561d04da54eae (diff) | |
download | chef-890e090e74eb435b8ed04b61a6a41f4649f4b9ab.tar.gz |
Merge pull request #8370 from chef/lcg/empty-override-runlist
Allow empty strings in -o to result in empty override run list
Diffstat (limited to 'spec')
-rw-r--r-- | spec/integration/client/client_spec.rb | 67 | ||||
-rw-r--r-- | spec/unit/policy_builder/expand_node_object_spec.rb | 6 |
2 files changed, 70 insertions, 3 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index afe94f854e..006839be3f 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -233,6 +233,7 @@ describe "chef-client" do THECONSTANT = '1' end EOM + file "arbitrary.rb", <<~EOM file #{path_to('tempfile.txt').inspect} do content ::Blah::THECONSTANT @@ -245,6 +246,72 @@ describe "chef-client" do expect(IO.read(path_to("tempfile.txt"))).to eq("1") end + it "should run recipes specified directly on the command line AFTER recipes in the run list (without an override_runlist this time)" do + file "config/client.rb", <<~EOM + local_mode true + client_key #{path_to('mykey.pem').inspect} + cookbook_path #{path_to('cookbooks').inspect} + EOM + + file "config/dna.json", <<~EOM + { + "run_list": [ "recipe[x::constant_definition]" ] + } + EOM + + file "cookbooks/x/recipes/constant_definition.rb", <<~EOM + class ::Blah + THECONSTANT = '1' + end + EOM + + file "arbitrary.rb", <<~EOM + file #{path_to('tempfile.txt').inspect} do + content ::Blah::THECONSTANT + end + EOM + + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -j \"#{path_to('config/dna.json')}\" arbitrary.rb", cwd: path_to("")) + result.error! + + expect(IO.read(path_to("tempfile.txt"))).to eq("1") + end + + it "an override_runlist of an empty string should allow a recipe specified directly on the command line to be the only one run" do + file "config/client.rb", <<~EOM + local_mode true + client_key #{path_to('mykey.pem').inspect} + cookbook_path #{path_to('cookbooks').inspect} + class ::Blah + THECONSTANT = "1" + end + EOM + + file "config/dna.json", <<~EOM + { + "run_list": [ "recipe[x::constant_definition]" ] + } + EOM + + file "cookbooks/x/recipes/constant_definition.rb", <<~EOM + class ::Blah + THECONSTANT = "2" + end + EOM + + file "arbitrary.rb", <<~EOM + raise "this test failed" unless ::Blah::THECONSTANT == "1" + file #{path_to('tempfile.txt').inspect} do + content ::Blah::THECONSTANT + end + EOM + + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -j \"#{path_to('config/dna.json')}\" -o \"\" arbitrary.rb", cwd: path_to("")) + result.error! + + expect(IO.read(path_to("tempfile.txt"))).to eq("1") + end + end it "should complete with success when passed the -z flag" do diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb index 122c960c11..d622bfcbb4 100644 --- a/spec/unit/policy_builder/expand_node_object_spec.rb +++ b/spec/unit/policy_builder/expand_node_object_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2014-2017, Chef Software Inc. +# Copyright:: Copyright 2014-2019, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,7 +42,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do expect(policy_builder).to respond_to(:finish_load_node) end - it "implements a build_node method" do + it "implements a build_node method" do expect(policy_builder).to respond_to(:build_node) end @@ -224,7 +224,7 @@ describe Chef::PolicyBuilder::ExpandNodeObject do end it "reports that a temporary policy is being used" do - expect(policy_builder.temporary_policy?).to be_truthy + expect(policy_builder.temporary_policy?).to be true end end |