Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vshah23 committed Dec 5, 2022
1 parent 950d338 commit 6bb0cf5
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions log/event_print_test.go
Expand Up @@ -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,
Expand All @@ -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 |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -146,15 +147,15 @@ 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,
},
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 |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -163,14 +164,15 @@ 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,
},
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 |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -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 |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -212,15 +219,15 @@ 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,
},
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 |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -229,15 +236,15 @@ 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,
},
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 |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand Down Expand Up @@ -271,6 +278,7 @@ func TestStepFooterPrinting(t *testing.T) {
params: StepFinishedParams{
InternalStatus: models.StepRunStatusCodeSuccess,
Status: "success",
StatusReason: "",
Title: "Step",
RunTime: 65748,
Update: &StepUpdate{
Expand Down

0 comments on commit 6bb0cf5

Please sign in to comment.