New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bsc#1036440: Warning messages shouldn't open UI in command-line mode #580
Changes from 5 commits
0f30117
b72de08
214b168
cf4831c
c6dafdc
d06a6f6
369bc5e
ef4a4f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#! /usr/bin/env rspec | ||
# | ||
require_relative "test_helper" | ||
require "yaml" | ||
|
||
Yast.import "Report" | ||
Yast.import "Mode" | ||
|
||
describe Yast::Report do | ||
before { subject.ClearAll } | ||
|
||
describe ".Warning" do | ||
let(:show) { true } | ||
let(:message) { "Message" } | ||
|
||
context "while in command-line mode" do | ||
before(:each) do | ||
allow(Yast::Mode).to receive(:commandline).and_return(true) | ||
end | ||
|
||
it "prints the message only on console" do | ||
expect(Yast::CommandLine).to receive("Print") | ||
.with(/#{message}/) | ||
expect(Yast::Popup).to_not receive("Warning") | ||
expect(Yast::Popup).to_not receive("TimedWarning") | ||
subject.Warning(message) | ||
end | ||
end | ||
|
||
context "while in UI mode and timeout is disabled" do | ||
let(:timeout) { 0 } | ||
|
||
before(:each) do | ||
subject.DisplayWarnings(show, timeout) | ||
allow(Yast::Mode).to receive(:commandline).and_return(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are going to mock before do
allow(Yast::Mode).to receive(:commandline).and_return(commandline?)
end
context "while in UI mode and timeout is disabled" do
let(:timeout) { 0 }
let(:commandline?) { false }
it "shows a popup" do
#...
end
end |
||
end | ||
|
||
it "shows a popup" do | ||
expect(Yast::Popup).to receive("Warning").with(/#{message}/) | ||
subject.Warning(message) | ||
end | ||
end | ||
|
||
context "while in UI mode and timeout is enabled" do | ||
let(:timeout) { 1 } | ||
|
||
before(:each) do | ||
subject.DisplayWarnings(show, timeout) | ||
allow(Yast::Mode).to receive(:commandline).and_return(false) | ||
end | ||
|
||
it "shows timed popup" do | ||
expect(Yast::Popup).to receive("TimedWarning").with(/#{message}/, timeout) | ||
subject.Warning(message) | ||
end | ||
end | ||
end | ||
|
||
describe ".Error" do | ||
let(:show) { true } | ||
let(:message) { "Message" } | ||
|
||
context "while in command-line mode" do | ||
before(:each) do | ||
allow(Yast::Mode).to receive(:commandline).and_return(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same than above. I would move this line to the outer before block. |
||
end | ||
|
||
it "prints the message only on console" do | ||
expect(Yast::CommandLine).to receive("Print") | ||
.with(/#{message}/) | ||
expect(Yast::Popup).to_not receive("Error") | ||
expect(Yast::Popup).to_not receive("TimedError") | ||
subject.Error(message) | ||
end | ||
end | ||
|
||
context "while in UI mode and timeout is disabled" do | ||
let(:timeout) { 0 } | ||
|
||
before(:each) do | ||
subject.DisplayErrors(show, timeout) | ||
allow(Yast::Mode).to receive(:commandline).and_return(false) | ||
end | ||
|
||
it "shows a popup" do | ||
expect(Yast::Popup).to receive("Error").with(/#{message}/) | ||
subject.Error(message) | ||
end | ||
end | ||
|
||
context "while in UI mode and timeout is enabled" do | ||
let(:timeout) { 1 } | ||
|
||
before(:each) do | ||
subject.DisplayErrors(show, timeout) | ||
allow(Yast::Mode).to receive(:commandline).and_return(false) | ||
end | ||
|
||
it "shows a timed popup" do | ||
expect(Yast::Popup).to receive("TimedError").with(/#{message}/, timeout) | ||
subject.Error(message) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
------------------------------------------------------------------- | ||
Mon May 29 08:19:46 UTC 2017 - gsouza@suse.com | ||
|
||
- bsc#1036440: Warning messages shouldn't open UI in command-line | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually write it like this:
|
||
mode | ||
- 3.1.155.8 | ||
|
||
------------------------------------------------------------------- | ||
Tue May 9 11:44:54 UTC 2017 - mvidner@suse.com | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for consistence, I would use
:Warning
symbol instead of the string.