From 21a30afe16ba5aee004817a96da24738fe5d174f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Thu, 13 Dec 2018 12:38:00 +0000 Subject: [PATCH 1/3] Fixed return code --- src/modules/NtpClient.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/NtpClient.rb b/src/modules/NtpClient.rb index 893de720..3a5daac4 100644 --- a/src/modules/NtpClient.rb +++ b/src/modules/NtpClient.rb @@ -203,7 +203,7 @@ def sync_once(server) ) log.info("'sntp #{server}' returned #{ret}") - ret["exit"] + ret end # Reads and returns all known countries with their country codes From 2a9185543bc9c2f4ec9915ba4052e6b9e1e8247a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Thu, 13 Dec 2018 12:48:20 +0000 Subject: [PATCH 2/3] Bump version & changelog. --- package/yast2-ntp-client.changes | 6 ++++++ package/yast2-ntp-client.spec | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package/yast2-ntp-client.changes b/package/yast2-ntp-client.changes index 34c9aa20..224b6e6a 100644 --- a/package/yast2-ntp-client.changes +++ b/package/yast2-ntp-client.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Dec 13 12:45:27 UTC 2018 - knut.anderssen@suse.com + +- Fixed sync_once method return value (bsc#1108497) +- 3.2.18 + ------------------------------------------------------------------- Fri Sep 7 15:20:26 UTC 2018 - dgonzalez@suse.com diff --git a/package/yast2-ntp-client.spec b/package/yast2-ntp-client.spec index fcf0cb28..9d324bfe 100644 --- a/package/yast2-ntp-client.spec +++ b/package/yast2-ntp-client.spec @@ -17,7 +17,7 @@ Name: yast2-ntp-client -Version: 3.2.17 +Version: 3.2.18 Release: 0 Summary: YaST2 - NTP Client Configuration License: GPL-2.0+ From 388ca2fd35f9845505930d3e5e6395d96e7bca34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Alejandro=20Anderssen=20Gonz=C3=A1lez?= Date: Thu, 13 Dec 2018 13:21:58 +0000 Subject: [PATCH 3/3] Added NtpClient.sync_code unit test --- test/ntp_client_test.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/ntp_client_test.rb b/test/ntp_client_test.rb index f007359c..e594ae10 100644 --- a/test/ntp_client_test.rb +++ b/test/ntp_client_test.rb @@ -572,6 +572,35 @@ end end + describe "#sync_once" do + let(:output) { 0 } + let(:server) { "sntp.server.de" } + + before do + allow(Yast::SCR).to receive(:Execute) + end + + it "syncs the system time against the specified server" do + expect(Yast::SCR).to receive(:Execute) + .with(Yast::Path.new(".target.bash"), + "/usr/sbin/sntp -S -K /dev/null -l /var/log/YaST2/sntp.log " \ + "-t 5 -c '#{server}'") + .and_return(output) + + subject.sync_once(server) + end + + it "returns the syncronization exit code" do + expect(Yast::SCR).to receive(:Execute) + .with(Yast::Path.new(".target.bash"), + "/usr/sbin/sntp -S -K /dev/null -l /var/log/YaST2/sntp.log " \ + "-t 5 -c '#{server}'") + .and_return(output) + + expect(subject.sync_once(server)).to eql(0) + end + end + describe "#sntp_test" do let(:ip_version) { 4 } let(:server) { "sntp.server.de" }