Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vshah23 committed Dec 6, 2022
1 parent 45f9389 commit 5df29c9
Showing 1 changed file with 47 additions and 17 deletions.
64 changes: 47 additions & 17 deletions log/event_print_test.go
Expand Up @@ -113,6 +113,8 @@ func TestStepFooterPrinting(t *testing.T) {
params: StepFinishedParams{
InternalStatus: models.StepRunStatusCodeSuccess,
Status: "success",
StatusReason: "",
ShortReason: "",
Title: "Normal step name",
RunTime: 1234567,
LastStep: true,
Expand All @@ -130,14 +132,16 @@ func TestStepFooterPrinting(t *testing.T) {
InternalStatus: models.StepRunStatusCodeFailed,
Status: "failed",
StatusReason: "exit code: 1",
ShortReason: "exit code: 1",
Title: "Loooooooooooooooooooooooooooooooooong step name",
RunTime: 9999,
LastStep: true,
},
expectedOutput: []string{
"exit code: 1",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \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 +150,17 @@ 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.",
ShortReason: "exit code: 1",
Title: "Simple Git",
RunTime: 3333,
LastStep: true,
},
expectedOutput: []string{
"This Step failed, but it was marked as “is_skippable”, so the build continued.",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[33;1m!\u001B[0m | \u001B[33;1mSimple Git (exit code: 2) \u001B[0m | 3.33 sec |",
"| \x1b[33;1m!\x1b[0m | \x1b[33;1mSimple Git (exit code: 1) \x1b[0m | 3.33 sec |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -163,14 +169,17 @@ 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”.",
ShortReason: "skipped",
Title: "Step",
RunTime: 654321,
LastStep: true,
},
expectedOutput: []string{
"This Step was skipped, because a previous Step failed, and this Step was not marked “is_always_run”.",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[34;1m-\u001B[0m | \u001B[34;1mStep \u001B[0m | 10.9 min |",
"| \x1b[34;1m-\x1b[0m | \x1b[34;1mStep (skipped) \x1b[0m | 10.9 min |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -179,14 +188,21 @@ 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
`,
ShortReason: "skipped due to run_if",
Title: "Step",
RunTime: 42424242,
LastStep: true,
},
expectedOutput: []string{
"\nThis Step was skipped, because its “run_if” expression evaluated to false.\n\nThe “run_if” expression was: false\n",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[34;1m-\u001B[0m | \u001B[34;1mStep \u001B[0m | 12 hour |",
"| \x1b[34;1m-\x1b[0m | \x1b[34;1mStep (skipped due to run_if) \x1b[0m | 12 hour |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -196,14 +212,16 @@ func TestStepFooterPrinting(t *testing.T) {
InternalStatus: models.StepRunStatusCodePreparationFailed,
Status: "preparation_failed",
StatusReason: "exit code: 3",
ShortReason: "exit code: 3",
Title: "Step",
RunTime: 11111,
LastStep: true,
},
expectedOutput: []string{
"exit code: 3",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[31;1mx\u001B[0m | \u001B[31;1mStep (exit code: 3) \u001B[0m | 11.11 sec |",
"| \x1b[31;1mx\x1b[0m | \x1b[31;1mStep (exit code: 3) \x1b[0m | 11.11 sec |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -212,15 +230,17 @@ 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.",
ShortReason: "timed out",
Title: "Step",
RunTime: 99099,
LastStep: true,
},
expectedOutput: []string{
"This Step timed out after 5m.",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[31;1m/\u001B[0m | \u001B[31;1mStep (timed out) \u001B[0m | 1.7 min |",
"| \x1b[31;1m/\x1b[0m | \x1b[31;1mStep (timed out) \x1b[0m | 1.7 min |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -229,15 +249,17 @@ 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.",
ShortReason: "timed out due to no output",
Title: "Step",
RunTime: 101,
LastStep: true,
},
expectedOutput: []string{
"This Step failed, because it has not sent any output for 4m.",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \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;1mStep (timed out due to no output) \x1b[0m | 0.10 sec |",
"+---+---------------------------------------------------------------+----------+",
},
},
Expand All @@ -247,6 +269,7 @@ func TestStepFooterPrinting(t *testing.T) {
InternalStatus: models.StepRunStatusCodeFailed,
Status: "failed",
StatusReason: "exit code: 11",
ShortReason: "exit code: 11",
Title: "Failed step",
RunTime: 88888,
SupportURL: "https://issue-url-issue-url-issue-url-issue-url-issue-url-issue-url-issue-url-issue-url",
Expand All @@ -257,9 +280,10 @@ func TestStepFooterPrinting(t *testing.T) {
LastStep: true,
},
expectedOutput: []string{
"exit code: 11",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[31;1mx\u001B[0m | \u001B[31;1mFailed step (exit code: 11) \u001B[0m | 1.5 min |",
"| \x1b[31;1mx\x1b[0m | \x1b[31;1mFailed step (exit code: 11) \x1b[0m | 1.5 min |",
"+---+---------------------------------------------------------------+----------+",
"| Issue tracker: https://issue-url-issue-url-issue-url-issue-url-issue-url-... |",
"| Source: https://source-code-url |",
Expand All @@ -271,6 +295,8 @@ func TestStepFooterPrinting(t *testing.T) {
params: StepFinishedParams{
InternalStatus: models.StepRunStatusCodeSuccess,
Status: "success",
StatusReason: "",
ShortReason: "",
Title: "Step",
RunTime: 65748,
Update: &StepUpdate{
Expand Down Expand Up @@ -298,6 +324,7 @@ func TestStepFooterPrinting(t *testing.T) {
InternalStatus: models.StepRunStatusCodeFailed,
Status: "failed",
StatusReason: "exit code: 42",
ShortReason: "exit code: 42",
Title: "Loooooooooong step naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaame",
RunTime: 223,
Deprecation: &StepDeprecation{
Expand All @@ -307,12 +334,13 @@ func TestStepFooterPrinting(t *testing.T) {
LastStep: true,
},
expectedOutput: []string{
"exit code: 42",
"| |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[31;1mx\u001B[0m | \u001B[31;1m[Deprecated]\u001B[0m \u001B[31;1mLoooooooooong step naaaaaaaaa... (exit code: 42)\u001B[0m | 0.22 sec |",
"| \x1b[31;1mx\x1b[0m | \x1b[31;1m[Deprecated]\x1b[0m \x1b[31;1mLoooooooooong step naaaaaaaaa... (exit code: 42)\x1b[0m | 0.22 sec |",
"+---+---------------------------------------------------------------+----------+",
"| \u001B[31;1mRemoval date:\u001B[0m 2022-10-26 |",
"| \u001B[31;1mRemoval notes:\u001B[0m Lorem ipsum dolor sit amet, consectetur adipiscing elit. In |",
"| \x1b[31;1mRemoval date:\x1b[0m 2022-10-26 |",
"| \x1b[31;1mRemoval notes:\x1b[0m Lorem ipsum dolor sit amet, consectetur adipiscing elit. In |",
"| at ipsum nec orci convallis efficitur. Nulla ultrices eros non nisi tempus |",
"| feugiat. Donec ac sapien in odio ultrices ullamcorper vel id erat. Interdum |",
"| et malesuada fames ac ante ipsum primis in faucibus. Sed sed placerat |",
Expand All @@ -325,6 +353,8 @@ func TestStepFooterPrinting(t *testing.T) {
params: StepFinishedParams{
InternalStatus: models.StepRunStatusCodeSuccess,
Status: "success",
StatusReason: "",
ShortReason: "",
Title: "Regular step",
RunTime: 111111111111,
Errors: []StepError{
Expand Down

0 comments on commit 5df29c9

Please sign in to comment.