Skip to content

Commit

Permalink
Fix MakeProposal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Feb 20, 2020
1 parent acaa58c commit 7d8c881
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/ntp_client_proposal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

describe "#MakeProposal" do
let(:dhcp_ntp_servers) { [] }
let(:config_was_read?) { false }
let(:ntp_was_selected?) { false }

before do
allow(Yast::Lan).to receive(:dhcp_ntp_servers)
Expand All @@ -25,6 +27,10 @@
allow(Yast::Timezone).to receive(:timezone).and_return("Europe/Berlin")
allow(Yast::Timezone).to receive(:GetCountryForTimezone)
.with("Europe/Berlin").and_return("de")
allow(Yast::NtpClient).to receive(:config_has_been_read).and_return(config_was_read?)
allow(Yast::NtpClient).to receive(:ntp_selected).and_return(ntp_was_selected?)
allow(Yast::NtpClient).to receive(:GetUsedNtpServers)
.and_return(["2.opensuse.pool.ntp.org"])
end

context "when NTP servers were found via DHCP" do
Expand Down Expand Up @@ -56,6 +62,32 @@
subject.MakeProposal
end
end

context "when the NTP configuration has been read (from chrony)" do
let(:config_was_read?) { true }

it "proposes the known public servers for the current timezone" do
expect(Yast::UI).to receive(:ChangeWidget) do |*args|
items = args.last
hostnames = items.map { |i| i[1] }
expect(hostnames).to eq(["2.opensuse.pool.ntp.org"])
end
subject.MakeProposal
end
end

context "when the NTP server was already selected" do
let(:ntp_was_selected?) { true }

it "proposes the known public servers for the current timezone" do
expect(Yast::UI).to receive(:ChangeWidget) do |*args|
items = args.last
hostnames = items.map { |i| i[1] }
expect(hostnames).to eq(["2.opensuse.pool.ntp.org"])
end
subject.MakeProposal
end
end
end

describe "#Write" do
Expand Down

0 comments on commit 7d8c881

Please sign in to comment.