diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-08-18 14:18:50 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-08-18 14:18:50 -0700 |
commit | 5034aeaccc9e70be5bedd994893a010a9c19842c (patch) | |
tree | 8ab7e9f8078ae67d6dee0ac4a1cfab1ed15c5a0a | |
parent | 2c4130c520c8819cb75f18eff7bc8c1312660b3b (diff) | |
download | chef-5034aeaccc9e70be5bedd994893a010a9c19842c.tar.gz |
Add spec for windows as well
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/timezone.rb | 2 | ||||
-rw-r--r-- | spec/unit/resource/timezone_spec.rb | 17 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/chef/resource/timezone.rb b/lib/chef/resource/timezone.rb index 98be3a2fcc..5bcd6c0458 100644 --- a/lib/chef/resource/timezone.rb +++ b/lib/chef/resource/timezone.rb @@ -74,7 +74,7 @@ class Chef # @since 14.7 # @return [String] timezone id def current_windows_tz - tz_shellout = shell_out("tzutil /g") + tz_shellout = shell_out!("tzutil /g") raise "There was an error running the tzutil command" if tz_shellout.exitstatus == 1 tz_shellout.stdout.strip diff --git a/spec/unit/resource/timezone_spec.rb b/spec/unit/resource/timezone_spec.rb index ca71ccb679..a0205b8d06 100644 --- a/spec/unit/resource/timezone_spec.rb +++ b/spec/unit/resource/timezone_spec.rb @@ -20,9 +20,13 @@ require "spec_helper" describe Chef::Resource::Timezone do let(:resource) { Chef::Resource::Timezone.new("fakey_fakerton") } + let(:shellout_tzutil) do + double("shell_out!", stdout: "UTC\n", exitstatus: 0, error?: false) + end + # note: This weird indention is correct let(:shellout_timedatectl) do - double("shell_out", exitstatus: 0, error?: false, stdout: <<-OUTPUT) + double("shell_out!", exitstatus: 0, error?: false, stdout: <<-OUTPUT) Local time: Tue 2020-08-18 20:55:05 UTC Universal time: Tue 2020-08-18 20:55:05 UTC RTC time: Tue 2020-08-18 20:55:05 @@ -34,11 +38,11 @@ systemd-timesyncd.service active: yes end let(:shellout_systemsetup_fail) do - double("shell_out", stdout: "You need administrator access to run this tool... exiting!", exitstatus: 0, error?: false) # yes it's a non-error exit + double("shell_out!", stdout: "You need administrator access to run this tool... exiting!", exitstatus: 0, error?: false) # yes it's a non-error exit end let(:shellout_systemsetup) do - double("shell_out", stdout: "Time Zone: UTC", exitstatus: 0, error?: false) + double("shell_out!", stdout: "Time Zone: UTC", exitstatus: 0, error?: false) end it "sets resource name as :timezone" do @@ -80,4 +84,11 @@ systemd-timesyncd.service active: yes expect(resource.current_systemd_tz).to eql("Etc/UTC") end end + + describe "#current_windows_tz?" do + it "returns the TZ" do + expect(resource).to receive(:shell_out!).and_return(shellout_tzutil) + expect(resource.current_windows_tz).to eql("UTC") + end + end end |