diff options
author | vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2018-07-13 11:22:39 +0530 |
---|---|---|
committer | vasu1105 <vasundhara.jagdale@msystechnologies.com> | 2018-07-25 09:31:41 +0530 |
commit | 5b7f53dc6253fe7da492da2392202575df3e3cd3 (patch) | |
tree | a4c36a9960b911e564d70b522926290a1d1e88bd /spec | |
parent | 98762283604d272c39c9993dd407648f52db5c96 (diff) | |
download | chef-5b7f53dc6253fe7da492da2392202575df3e3cd3.tar.gz |
Add support for setting task priority
Signed-off-by: vasu1105 <vasundhara.jagdale@msystechnologies.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/resource/windows_task_spec.rb | 102 | ||||
-rw-r--r-- | spec/unit/resource/windows_task_spec.rb | 14 |
2 files changed, 116 insertions, 0 deletions
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb index a4cee114f4..02c84d5229 100644 --- a/spec/functional/resource/windows_task_spec.rb +++ b/spec/functional/resource/windows_task_spec.rb @@ -1179,6 +1179,108 @@ describe Chef::Resource::WindowsTask, :windows_only do end end + describe "priority" do + after { delete_task } + subject do + new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) + new_resource.command task_name + new_resource.frequency :once + new_resource.execution_time_limit = 259200 / 60 # converting "PT72H" into minutes and passing here since win32-taskscheduler accespts this + new_resource + end + + it "default sets to 7" do + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("below_normal_7") + end + + it "0 sets priority level to critical" do + subject.priority = 0 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("critical") + end + + it "2 sets priority level to highest" do + subject.priority = 1 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("highest") + end + + it "2 sets priority level to above_normal" do + subject.priority = 2 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("above_normal_2") + end + + it "3 sets priority level to above_normal" do + subject.priority = 3 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("above_normal_3") + end + + it "4 sets priority level to normal" do + subject.priority = 4 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("normal_4") + end + + it "5 sets priority level to normal" do + subject.priority = 5 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("normal_5") + end + + it "6 sets priority level to normal" do + subject.priority = 6 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("normal_6") + end + + it "7 sets priority level to below_normal" do + subject.priority = 7 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("below_normal_7") + end + + it "8 sets priority level to below_normal" do + subject.priority = 8 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("below_normal_8") + end + + it "9 sets priority level to lowest" do + subject.priority = 9 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("lowest") + end + + it "10 sets priority level to idle" do + subject.priority = 10 + call_for_create_action + current_resource = call_for_load_current_resource + expect(current_resource.task.priority).to eq("idle") + end + + it "is idempotent" do + subject.priority 8 + subject.run_action(:create) + subject.run_action(:create) + expect(subject).not_to be_updated_by_last_action + end + + end + describe "Examples of idempotent checks for each frequency" do after { delete_task } context "For frequency :once" do diff --git a/spec/unit/resource/windows_task_spec.rb b/spec/unit/resource/windows_task_spec.rb index 6dbda35274..cbf15092f5 100644 --- a/spec/unit/resource/windows_task_spec.rb +++ b/spec/unit/resource/windows_task_spec.rb @@ -153,6 +153,20 @@ describe Chef::Resource::WindowsTask, :windows_only do end end + context "priority" do + it "default value is 7" do + expect(resource.priority).to eq(7) + end + + it "raise error when priority value less than 0" do + expect { resource.priority (-1) }.to raise_error(Chef::Exceptions::ValidationFailed, "Option priority's value -1 should be in range of 0 to 10!") + end + + it "raise error when priority values is greater than 10" do + expect { resource.priority 11 }.to raise_error(Chef::Exceptions::ValidationFailed, "Option priority's value 11 should be in range of 0 to 10!") + end + end + context "#validate_start_time" do it "raises error if start_time is nil when frequency `:once`" do resource.frequency :once |