summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornimisha <nimisha.sharad@msystechnologies.com>2017-11-15 17:28:13 +0530
committernimisha <nimisha.sharad@msystechnologies.com>2017-11-15 18:31:46 +0530
commit1cfafab4c9b2f65221dfc5615c7dd7d7b51102a4 (patch)
treef0493f80b89c02e89c6d5f84e42006e6037900e6
parent7576c5c6618570b4d20a1f693a0b07761bac3404 (diff)
downloadchef-1cfafab4c9b2f65221dfc5615c7dd7d7b51102a4.tar.gz
Unit tests for invalid date and starttime error
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
-rw-r--r--spec/unit/provider/windows_task_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/provider/windows_task_spec.rb b/spec/unit/provider/windows_task_spec.rb
index 55a1e77e4e..d45531f3dc 100644
--- a/spec/unit/provider/windows_task_spec.rb
+++ b/spec/unit/provider/windows_task_spec.rb
@@ -110,6 +110,33 @@ describe Chef::Provider::WindowsTask do
expect(new_resource).not_to be_updated_by_last_action
end
+ it "sets the start_time in 24hr format while updating an existing task" do
+ # task_hash has start_time = "1:12:00 PM"
+ allow(provider).to receive(:load_task_hash).and_return(task_hash)
+ provider.load_current_resource
+ allow(provider).to receive(:task_need_update?).and_return(true)
+ allow(provider).to receive(:convert_system_date_to_mm_dd_yyyy).and_return("03/30/2017")
+ allow(provider).to receive(:run_schtasks)
+ provider.run_action(:create)
+ # start_time gets set in 24hr format for new_resource
+ expect(new_resource.start_time).to eq("13:12")
+ expect(new_resource).to be_updated_by_last_action
+ end
+
+ it "sets the start_day in mm/dd/yyyy format while updating an existing task" do
+ # start_day in yyyy-MM-dd format
+ task_hash[:StartDate] = "2017-03-30"
+ allow(provider).to receive(:load_task_hash).and_return(task_hash)
+ current_resource = provider.load_current_resource
+ allow(provider).to receive(:task_need_update?).and_return(true)
+ allow(provider).to receive(:convert_system_date_format_to_ruby_date_format).and_return("%Y-%m-%d")
+ allow(provider).to receive(:run_schtasks)
+ provider.run_action(:create)
+ # start_day gets set in mm/dd/yyyy format for new_resource
+ expect(new_resource.start_day).to eq("03/30/2017")
+ expect(new_resource).to be_updated_by_last_action
+ end
+
context "when task is not existing" do
before do
allow(provider).to receive(:load_task_hash)