Skip to content

Commit

Permalink
replace old testsuite for make proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Feb 5, 2020
1 parent 26158b2 commit 4999c8f
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 66 deletions.
8 changes: 3 additions & 5 deletions timezone/src/modules/Timezone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,11 @@ def ProposeLocaltime

# Return proposal list of strings.
#
# @param [Boolean] force_reset
# boolean language_changed
# @param [Boolean] force_reset If force_reset is true reset the module
# to the timezone stored in default_timezone.
# @param [Boolean] language_changed
#
# @return [Array] user readable description.
#
# If force_reset is true reset the module to the timezone
# stored in default_timezone.
def MakeProposal(force_reset, language_changed)
Builtins.y2milestone("force_reset: %1", force_reset)
Builtins.y2milestone(
Expand Down
82 changes: 82 additions & 0 deletions timezone/test/Timezone_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,86 @@
expect(subject.Summary).to include("<ul>")
end
end

describe "#MakeProposal" do
context "force_reset is set to true" do
context "language_changed is set to true" do
it "resets zonemap" do
expect(subject).to receive(:ResetZonemap).and_call_original

subject.MakeProposal(true, true)
end
end

it "sets hwclock according to proposeLocalTime" do
allow(subject).to receive(:ProposeLocaltime).and_return(false)

subject.MakeProposal(true, true)

expect(subject.hwclock).to eq "-u"
end

it "sets timezone to default and change system clock" do
subject.default_timezone = "US/Pacific"
expect(subject).to receive(:Set).with("US/Pacific", true).and_call_original

subject.MakeProposal(true, true)

expect(subject.timezone).to eq "US/Pacific"
end

it "clears used decision flag" do
subject.user_decision = true

subject.MakeProposal(true, true)

expect(subject.user_decision).to eq false
end

it "returns array of strings" do
expect(subject.MakeProposal(true, true)).to be_a(Array)
expect(subject.MakeProposal(true, true)).to all(be_a(::String))
end
end

context "force_reset is set to false" do
context "language_changed is set to true" do
it "resets zonemap" do
expect(subject).to receive(:ResetZonemap).and_call_original

subject.MakeProposal(false, true)
end

# FIXME: this depends on complex condition hard to explain here
it "writes timezone" do
subject.user_decision = true

subject.timezone = "US/Pacific"
expect(subject).to receive(:Set).with("US/Pacific", true).and_call_original

subject.MakeProposal(false, true)
end
end

context "language_changed is set to false" do
# FIXME: this depends on complex condition hard to explain here
it "sets local timezone according to Language.language" do
subject.user_decision = false

allow(Yast::Language).to receive(:language).and_return("cs_CZ")

expect(subject).to receive(:Set).with("Europe/Prague", true).and_call_original

subject.MakeProposal(false, false)

expect(subject.default_timezone).to eq "Europe/Prague"
end
end

it "returns array of strings" do
expect(subject.MakeProposal(false, true)).to be_a(Array)
expect(subject.MakeProposal(false, true)).to all(be_a(::String))
end
end
end
end
Empty file.
8 changes: 0 additions & 8 deletions timezone/testsuite/tests/MakeProposal.out

This file was deleted.

53 changes: 0 additions & 53 deletions timezone/testsuite/tests/MakeProposal.rb

This file was deleted.

0 comments on commit 4999c8f

Please sign in to comment.