diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2018-06-23 22:24:54 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2018-06-23 22:24:54 -0700 |
commit | 6e9b83b4ddf20f69129ca20d1f4bea074d73f59c (patch) | |
tree | 7c012a3782ebcfe0b4b0e9e646ee589ec24983ba /spec/support | |
parent | 78e28e201e2e196e214e946c153c8a6ae1aa2a3c (diff) | |
download | chef-6e9b83b4ddf20f69129ca20d1f4bea074d73f59c.tar.gz |
Add tests for `knife config`.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared/integration/knife_support.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb index 86764cad66..0a0d2d0c0c 100644 --- a/spec/support/shared/integration/knife_support.rb +++ b/spec/support/shared/integration/knife_support.rb @@ -24,7 +24,7 @@ require "chef/chef_fs/file_system_cache" module KnifeSupport DEBUG = ENV["DEBUG"] - def knife(*args, input: nil) + def knife(*args, input: nil, &block) # Allow knife('role from file roles/blah.json') rather than requiring the # arguments to be split like knife('role', 'from', 'file', 'roles/blah.json') # If any argument will have actual spaces in it, the long form is required. @@ -88,9 +88,15 @@ module KnifeSupport allow(File).to receive(:file?).and_call_original allow(File).to receive(:file?).with(File.expand_path("~/.chef/credentials")).and_return(false) + # Set a canary that is modified by the default null_config.rb config file. $__KNIFE_INTEGRATION_FAILSAFE_CHECK = "ole" + + # Allow tweaking the knife instance before configuration. + yield(instance) if block + instance.configure_chef + # The canary is incorrect, meaning the normal null_config.rb didn't run. Something is wrong. unless $__KNIFE_INTEGRATION_FAILSAFE_CHECK == "ole ole" raise Exception, "Potential misconfiguration of integration tests detected. Aborting test." end |