Skip to content

Commit

Permalink
Added NtpClient.sync_code unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Dec 13, 2018
1 parent 2a91855 commit 388ca2f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/ntp_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 388ca2f

Please sign in to comment.