-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5254 from jrafanie/fix_padding_calculation_since_…
…text_ignores_line_width Use ljust to left justify and pad strings
- Loading branch information
Showing
3 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
describe ReportFormatter::ReportText do | ||
include Spec::Support::ReportHelper | ||
|
||
before do | ||
allow(Charting).to receive(:backend).and_return(:text) | ||
allow(Charting).to receive(:format).and_return(:text) | ||
end | ||
|
||
it "expands report width for really long filter condition" do | ||
report = null_data_chart_with_complex_condition | ||
Timecop.freeze do | ||
result = render_report(report) { |r| r.options.ignore_table_width = true } | ||
|
||
expected = <<~TABLE | ||
+--------------------------------------------------------------------+ | ||
| Name | Hardware CPU Speed | Hardware Number of CPUs | Hardware RAM | | ||
+--------------------------------------------------------------------+ | ||
| Чук | | 4 | 6 GB | | ||
| Гек | | | 1 GB | | ||
+--------------------------------------------------------------------+ | ||
+--------------------------------------------------------------------+ | ||
|Report based filter fields: | | ||
|( Performance - VM : Activity Sample - Timestamp (Day/Time) IS "Last Hour" AND Performance - VM : CPU - Usage Rate for Collected Intervals (%) > 0 AND Performance - VM.VM and Instance : Type INCLUDES "Amazon" )| | ||
+--------------------------------------------------------------------+ | ||
| #{described_class.format_timezone(Time.zone.now)} | | ||
+--------------------------------------------------------------------+ | ||
TABLE | ||
result.lines.each_with_index do |line, index| | ||
expect(line.strip).to eq(expected.lines[index].strip) | ||
end | ||
end | ||
end | ||
|
||
it "renders basic text report" do | ||
report = null_data_chart | ||
Timecop.freeze do | ||
result = render_report(report) | ||
expected = <<~TABLE | ||
+--------------------------------------------------------------------+ | ||
| Name | Hardware CPU Speed | Hardware Number of CPUs | Hardware RAM | | ||
+--------------------------------------------------------------------+ | ||
| Чук | | 4 | 6 GB | | ||
| Гек | | | 1 GB | | ||
+--------------------------------------------------------------------+ | ||
+--------------------------------------------------------------------+ | ||
| #{described_class.format_timezone(Time.zone.now)} | | ||
+--------------------------------------------------------------------+ | ||
TABLE | ||
result.lines.each_with_index do |line, index| | ||
expect(line.strip).to eq(expected.lines[index].strip) | ||
end | ||
end | ||
end | ||
|
||
it "renders report with basic filter condition" do | ||
report = null_data_chart_with_basic_condition | ||
Timecop.freeze do | ||
result = render_report(report) | ||
expected = <<~TABLE | ||
+--------------------------------------------------------------------+ | ||
| Name | Hardware CPU Speed | Hardware Number of CPUs | Hardware RAM | | ||
+--------------------------------------------------------------------+ | ||
| Чук | | 4 | 6 GB | | ||
| Гек | | | 1 GB | | ||
+--------------------------------------------------------------------+ | ||
+--------------------------------------------------------------------+ | ||
|Report based filter fields: | | ||
| Name INCLUDES "Amazon" | | ||
+--------------------------------------------------------------------+ | ||
| #{described_class.format_timezone(Time.zone.now)} | | ||
+--------------------------------------------------------------------+ | ||
TABLE | ||
result.lines.each_with_index do |line, index| | ||
expect(line.strip).to eq(expected.lines[index].strip) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters