summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalim Afiune <afiune@chef.io>2017-03-13 12:12:12 -0400
committerTom Duffield <tom@chef.io>2017-03-16 14:06:57 -0500
commitd6a969be1142b31418b342d3f1c1e4ff18207e9c (patch)
treea406995c3288d8461acf4ef67d23b809688c8f98
parentf7c7942f103befba79f006bc0ea6d06d1ced70d4 (diff)
downloadchef-d6a969be1142b31418b342d3f1c1e4ff18207e9c.tar.gz
Update Chef::Shell tests
Signed-off-by: Salim Afiune <afiune@chef.io>
-rw-r--r--spec/unit/shell/shell_session_spec.rb35
1 files changed, 33 insertions, 2 deletions
diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb
index 259e6096a4..170767fbd6 100644
--- a/spec/unit/shell/shell_session_spec.rb
+++ b/spec/unit/shell/shell_session_spec.rb
@@ -77,6 +77,37 @@ describe Shell::ClientSession do
end
+describe Shell::SoloSession do
+ before do
+ Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
+ @chef_rest = double("Chef::ServerAPI")
+ @session = Shell::SoloSession.instance
+ @node = Chef::Node.build("foo")
+ @session.node = @node
+ @client = double("Chef::Client.new",
+ :run_ohai => true,
+ :load_node => true,
+ :build_node => true,
+ :register => true,
+ :sync_cookbooks => {})
+ end
+
+ it "builds the node's run_context with the proper environment" do
+ @session.instance_variable_set(:@client, @client)
+ @expansion = Chef::RunList::RunListExpansion.new(@node.chef_environment, [])
+
+ expect(@node.run_list).to receive(:expand).with(@node.chef_environment).and_return(@expansion)
+ expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(@chef_rest)
+ @session.rebuild_context
+ end
+
+ it "passes the shell CLI args to the client" do
+ expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client)
+ @session.send(:rebuild_node)
+ end
+
+end
+
describe Shell::StandAloneSession do
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
@@ -128,11 +159,11 @@ describe Shell::StandAloneSession do
end
-describe Shell::SoloSession do
+describe Shell::SoloLegacySession do
before do
Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] }
Chef::Config[:shell_solo] = true
- @session = Shell::SoloSession.instance
+ @session = Shell::SoloLegacySession.instance
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = @session.run_context = Chef::RunContext.new(@node, {}, @events)