summaryrefslogtreecommitdiff
path: root/spec/unit/knife/role_env_run_list_clear_spec.rb
diff options
context:
space:
mode:
authorWilliam Albenzi <walbenzi@gmail.com>2013-09-12 14:48:20 -0700
committerBryan McLellan <btm@opscode.com>2015-02-12 14:05:46 -0500
commit7579a6b62998f3a147d0c316c73c6b466566c453 (patch)
treee5402a11fdb65c4a77077ec49fbc94237350985e /spec/unit/knife/role_env_run_list_clear_spec.rb
parentc196fa94b5353402916d96b6b92ddb6a1830ab25 (diff)
downloadchef-7579a6b62998f3a147d0c316c73c6b466566c453.tar.gz
CHEF-4591: Knife commands to manipulate env_run_list on nodes
Diffstat (limited to 'spec/unit/knife/role_env_run_list_clear_spec.rb')
-rw-r--r--spec/unit/knife/role_env_run_list_clear_spec.rb100
1 files changed, 100 insertions, 0 deletions
diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb
new file mode 100644
index 0000000000..39e57b1055
--- /dev/null
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -0,0 +1,100 @@
+#
+# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Will Albenzi (<walbenzi@gmail.com>)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'spec_helper'
+
+describe Chef::Knife::RoleEnvRunListClear do
+ before(:each) do
+ Chef::Config[:role_name] = "will"
+ Chef::Config[:env_name] = "QA"
+ @setup = Chef::Knife::RoleEnvRunListAdd.new
+ @setup.name_args = [ "will", "QA", "role[monkey]", "role[person]" ]
+
+ @knife = Chef::Knife::RoleEnvRunListClear.new
+ @knife.config = {
+ :print_after => nil
+ }
+ @knife.name_args = [ "will", "QA" ]
+ @knife.stub!(:output).and_return(true)
+
+ @role = Chef::Role.new()
+ @role.name("will")
+ @role.stub!(:save).and_return(true)
+
+ @knife.ui.stub!(:confirm).and_return(true)
+ Chef::Role.stub!(:load).and_return(@role)
+
+ end
+
+
+
+ describe "run" do
+
+
+# it "should display all the things" do
+# @knife.run
+# @role.to_json.should == 'show all the things'
+# end
+
+ it "should load the node" do
+ Chef::Role.should_receive(:load).with("will").and_return(@role)
+ @knife.run
+ end
+
+ it "should remove the item from the run list" do
+ @setup.run
+ @knife.run
+ @role.run_list_for('QA')[0].should be_nil
+ @role.run_list[0].should be_nil
+ end
+
+ it "should save the node" do
+ @role.should_receive(:save).and_return(true)
+ @knife.run
+ end
+
+ it "should print the run list" do
+ @knife.should_receive(:output).and_return(true)
+ @knife.config[:print_after] = true
+ @setup.run
+ @knife.run
+ end
+
+ describe "should clear an environmental run list of roles and recipes" do
+ it "should remove the items from the run list" do
+ @setup.name_args = [ "will", "QA", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ]
+ @setup.run
+ @knife.name_args = [ 'will', 'QA' ]
+ @knife.run
+ @role.run_list_for('QA')[0].should be_nil
+ @role.run_list_for('PRD')[0].should == 'recipe[orange::chicken]'
+ @role.run_list_for('PRD')[1].should == 'role[monkey]'
+ @role.run_list_for('PRD')[2].should == 'recipe[duck::type]'
+ @role.run_list_for('PRD')[3].should == 'role[person]'
+ @role.run_list_for('PRD')[4].should == 'role[bird]'
+ @role.run_list_for('PRD')[5].should == 'role[town]'
+ end
+ end
+ end
+end
+
+
+