From f3cebcfbc09bb541e7b395e934cc8ac912bf1d1c Mon Sep 17 00:00:00 2001 From: lance6716 Date: Wed, 11 Dec 2024 12:36:23 +0800 Subject: [PATCH] lightning: allow long dbname printed in 1 line for error summary Signed-off-by: lance6716 --- pkg/lightning/errormanager/errormanager.go | 8 ++++---- pkg/lightning/errormanager/errormanager_test.go | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pkg/lightning/errormanager/errormanager.go b/pkg/lightning/errormanager/errormanager.go index cec0bc4cc352a..10e68266d77fd 100644 --- a/pkg/lightning/errormanager/errormanager.go +++ b/pkg/lightning/errormanager/errormanager.go @@ -1107,10 +1107,10 @@ func (em *ErrorManager) Output() string { t := table.NewWriter() t.AppendHeader(table.Row{"#", "Error Type", "Error Count", "Error Data Table"}) t.SetColumnConfigs([]table.ColumnConfig{ - {Name: "#", WidthMax: 6}, - {Name: "Error Type", WidthMax: 20}, - {Name: "Error Count", WidthMax: 12}, - {Name: "Error Data Table", WidthMax: 42}, + {Name: "#"}, + {Name: "Error Type"}, + {Name: "Error Count"}, + {Name: "Error Data Table"}, }) t.SetRowPainter(func(table.Row) text.Colors { return text.Colors{text.FgRed} diff --git a/pkg/lightning/errormanager/errormanager_test.go b/pkg/lightning/errormanager/errormanager_test.go index d6bab3cc58a26..7b02b2772a77e 100644 --- a/pkg/lightning/errormanager/errormanager_test.go +++ b/pkg/lightning/errormanager/errormanager_test.go @@ -707,4 +707,18 @@ func TestErrorMgrErrorOutput(t *testing.T) { "|\x1b[31m 4 \x1b[0m|\x1b[31m Unique Key Conflict \x1b[0m|\x1b[31m 100 \x1b[0m|\x1b[31m `error_info`.`conflict_view` \x1b[0m|\n" + "+---+---------------------+-------------+--------------------------------+\n" require.Equal(t, expected, output) + + em.schema = "long_long_long_long_long_long_long_long_dbname" + output = em.Output() + expected = "\n" + + "Import Data Error Summary: \n" + + "+---+---------------------+-------------+--------------------------------------------------------------------+\n" + + "| # | ERROR TYPE | ERROR COUNT | ERROR DATA TABLE |\n" + + "+---+---------------------+-------------+--------------------------------------------------------------------+\n" + + "|\x1b[31m 1 \x1b[0m|\x1b[31m Data Type \x1b[0m|\x1b[31m 100 \x1b[0m|\x1b[31m `long_long_long_long_long_long_long_long_dbname`.`type_error_v2` \x1b[0m|\n" + + "|\x1b[31m 2 \x1b[0m|\x1b[31m Data Syntax \x1b[0m|\x1b[31m 100 \x1b[0m|\x1b[31m `long_long_long_long_long_long_long_long_dbname`.`syntax_error_v2` \x1b[0m|\n" + + "|\x1b[31m 3 \x1b[0m|\x1b[31m Charset Error \x1b[0m|\x1b[31m 100 \x1b[0m|\x1b[31m \x1b[0m|\n" + + "|\x1b[31m 4 \x1b[0m|\x1b[31m Unique Key Conflict \x1b[0m|\x1b[31m 100 \x1b[0m|\x1b[31m `long_long_long_long_long_long_long_long_dbname`.`conflict_view` \x1b[0m|\n" + + "+---+---------------------+-------------+--------------------------------------------------------------------+\n" + require.Equal(t, expected, output) }