From 6bb0cf51117971af8de9a861df7215b9100fb6ab Mon Sep 17 00:00:00 2001 From: vikas Date: Mon, 5 Dec 2022 11:39:45 -0600 Subject: [PATCH] Fixed unit tests --- log/event_print_test.go | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/log/event_print_test.go b/log/event_print_test.go index df9e0a89..8ede3c98 100644 --- a/log/event_print_test.go +++ b/log/event_print_test.go @@ -113,6 +113,7 @@ func TestStepFooterPrinting(t *testing.T) { params: StepFinishedParams{ InternalStatus: models.StepRunStatusCodeSuccess, Status: "success", + StatusReason: "", Title: "Normal step name", RunTime: 1234567, LastStep: true, @@ -137,7 +138,7 @@ func TestStepFooterPrinting(t *testing.T) { expectedOutput: []string{ "| |", "+---+---------------------------------------------------------------+----------+", - "| \u001B[31;1mx\u001B[0m | \u001B[31;1mLoooooooooooooooooooooooooooooooooong step ... (exit code: 1)\u001B[0m | 10.00 sec |", + "| \x1b[31;1mx\x1b[0m | \x1b[31;1mLoooooooooooooooooooooooooooooooooong step ... (exit code: 1)\x1b[0m | 10.00 sec |", "+---+---------------------------------------------------------------+----------+", }, }, @@ -146,7 +147,7 @@ func TestStepFooterPrinting(t *testing.T) { params: StepFinishedParams{ InternalStatus: models.StepRunStatusCodeFailedSkippable, Status: "failed_skippable", - StatusReason: "exit code: 2", + StatusReason: "This Step failed, but it was marked as “is_skippable”, so the build continued.", Title: "Simple Git", RunTime: 3333, LastStep: true, @@ -154,7 +155,7 @@ func TestStepFooterPrinting(t *testing.T) { expectedOutput: []string{ "| |", "+---+---------------------------------------------------------------+----------+", - "| \u001B[33;1m!\u001B[0m | \u001B[33;1mSimple Git (exit code: 2) \u001B[0m | 3.33 sec |", + "| \x1b[33;1m!\x1b[0m | \x1b[33;1m (This Step failed, but it was marked as “is_skippable\xe2\x80...\x1b[0m | 3.33 sec |", "+---+---------------------------------------------------------------+----------+", }, }, @@ -163,6 +164,7 @@ func TestStepFooterPrinting(t *testing.T) { params: StepFinishedParams{ InternalStatus: models.StepRunStatusCodeSkipped, Status: "skipped", + StatusReason: "This Step was skipped, because a previous Step failed, and this Step was not marked “is_always_run”.", Title: "Step", RunTime: 654321, LastStep: true, @@ -170,7 +172,7 @@ func TestStepFooterPrinting(t *testing.T) { expectedOutput: []string{ "| |", "+---+---------------------------------------------------------------+----------+", - "| \u001B[34;1m-\u001B[0m | \u001B[34;1mStep \u001B[0m | 10.9 min |", + "| \x1b[34;1m-\x1b[0m | \x1b[34;1m (This Step was skipped, because a previous Step failed, a...\x1b[0m | 10.9 min |", "+---+---------------------------------------------------------------+----------+", }, }, @@ -179,14 +181,19 @@ func TestStepFooterPrinting(t *testing.T) { params: StepFinishedParams{ InternalStatus: models.StepRunStatusCodeSkippedWithRunIf, Status: "skipped_with_run_if", - Title: "Step", - RunTime: 42424242, - LastStep: true, + StatusReason: ` +This Step was skipped, because its “run_if” expression evaluated to false. + +The “run_if” expression was: false +`, + Title: "Step", + RunTime: 42424242, + LastStep: true, }, expectedOutput: []string{ "| |", "+---+---------------------------------------------------------------+----------+", - "| \u001B[34;1m-\u001B[0m | \u001B[34;1mStep \u001B[0m | 12 hour |", + "| \x1b[34;1m-\x1b[0m | \x1b[34;1m (\nThis Step was skipped, because its “run_if” express...\x1b[0m | 12 hour |", "+---+---------------------------------------------------------------+----------+", }, }, @@ -212,7 +219,7 @@ func TestStepFooterPrinting(t *testing.T) { params: StepFinishedParams{ InternalStatus: models.StepRunStatusAbortedWithCustomTimeout, Status: "aborted_with_custom_timeout", - StatusReason: "timed out", + StatusReason: "This Step timed out after 5m.", Title: "Step", RunTime: 99099, LastStep: true, @@ -220,7 +227,7 @@ func TestStepFooterPrinting(t *testing.T) { expectedOutput: []string{ "| |", "+---+---------------------------------------------------------------+----------+", - "| \u001B[31;1m/\u001B[0m | \u001B[31;1mStep (timed out) \u001B[0m | 1.7 min |", + "| \x1b[31;1m/\x1b[0m | \x1b[31;1mStep (This Step timed out after 5m.) \x1b[0m | 1.7 min |", "+---+---------------------------------------------------------------+----------+", }, }, @@ -229,7 +236,7 @@ func TestStepFooterPrinting(t *testing.T) { params: StepFinishedParams{ InternalStatus: models.StepRunStatusAbortedWithNoOutputTimeout, Status: "aborted_with_no_output", - StatusReason: "timed out due to no output", + StatusReason: "This Step failed, because it has not sent any output for 4m.", Title: "Step", RunTime: 101, LastStep: true, @@ -237,7 +244,7 @@ func TestStepFooterPrinting(t *testing.T) { expectedOutput: []string{ "| |", "+---+---------------------------------------------------------------+----------+", - "| \u001B[31;1m/\u001B[0m | \u001B[31;1mStep (timed out due to no output) \u001B[0m | 0.10 sec |", + "| \x1b[31;1m/\x1b[0m | \x1b[31;1m (This Step failed, because it has not sent any output for...\x1b[0m | 0.10 sec |", "+---+---------------------------------------------------------------+----------+", }, }, @@ -271,6 +278,7 @@ func TestStepFooterPrinting(t *testing.T) { params: StepFinishedParams{ InternalStatus: models.StepRunStatusCodeSuccess, Status: "success", + StatusReason: "", Title: "Step", RunTime: 65748, Update: &StepUpdate{