Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions testrunner/parsers/failure_format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/flanksource/clicky"
"github.com/flanksource/clicky/api/icons"
)

func TestParseFailureDetail_GomegaToHavePrefix(t *testing.T) {
Expand Down Expand Up @@ -230,6 +231,43 @@ func TestPrettyUsesFailureDetailSummary(t *testing.T) {
}
}

// TestPrettyRendersWarnedNodeAmber guards the case a warned node used to fall
// through to the default (pass) branch: a green check rendered right next to the
// node's warning message, contradicting both the amber summary counter and the
// Warned doc contract.
func TestPrettyRendersWarnedNodeAmber(t *testing.T) {
test := Test{
Name: "trace[watch]",
Warned: true,
Message: "start watch trace: deployment not found",
}

rendered := clicky.MustFormat(test.Pretty())
if strings.Contains(rendered, icons.Pass.Unicode) {
t.Errorf("a warned node must not render the pass icon, got %q", rendered)
}
if !strings.Contains(rendered, icons.Warning.Unicode) {
t.Errorf("expected the warning icon, got %q", rendered)
}
if !strings.Contains(rendered, "deployment not found") {
t.Errorf("expected the warning message, got %q", rendered)
}
}

// TestPrettyFailedWinsOverWarned pins the precedence Sum() uses: a node that is
// both failed and warned is a failure, and must render red.
func TestPrettyFailedWinsOverWarned(t *testing.T) {
test := Test{Name: "step", Failed: true, Warned: true, Message: "boom"}

rendered := clicky.MustFormat(test.Pretty())
if !strings.Contains(rendered, icons.Fail.Unicode) {
t.Errorf("a failed node stays red even when warned, got %q", rendered)
}
if strings.Contains(rendered, icons.Warning.Unicode) {
t.Errorf("a failure must not be downgraded to a warning, got %q", rendered)
}
}

func TestPrettyFallsBackToRawMessageWhenNoDetail(t *testing.T) {
test := Test{
Name: "weird",
Expand Down
6 changes: 6 additions & 0 deletions testrunner/parsers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ func (t Test) Pretty() api.Text {
case t.Failed:
s = s.Append(icons.Fail, "text-red-500")
textStyle = "text-red-500"
// A warned node completed with a non-blocking problem. Without this branch it
// falls through to the pass icon and renders a green check next to its warning
// message — the summary line counts it amber, so the tree must agree.
case t.Warned:
s = s.Append(icons.Warning, "text-amber-500")
textStyle = "text-amber-500"
default:
s = s.Add(icons.Pass)
}
Expand Down
Loading