v0.23.0 color, presets, certificates made at startup, cli.go, sink flush
Test / test (push) Canceled after 0s
Test / e2e (push) Canceled after 0s

This commit is contained in:
lixen committed 2026-10-04 03:44:12 -04:00
1 parent 15745682bc
commit bf410e1225
50 files changed
+2649 -426

No files matched your search

+25 -1
View File
@@ -1,6 +1,11 @@
package console
import "testing"
import (
"io"
"testing"
"github.com/lixenwraith/terminal/inline"
)
// Everything a terminal would act on is escaped; tabs and the final newline,
// which it only lays out, are kept.
@@ -23,3 +28,22 @@ func TestEscapeControlsKeepsOnlyLayout(t *testing.T) {
}
}
}
// The entry's level is painted where its line first names it as a whole
// word, in any case, longest name first; other words and levels stay plain.
func TestPaintLevelColorsTheFirstWholeName(t *testing.T) {
p := inline.New(io.Discard)
p.SetColor(true)
red, yellow := "\x1b[0;1;31m", "\x1b[0;33m"
for _, c := range []struct{ in, level, want string }{
{"2026 ERROR boom ERROR\n", "ERROR", "2026 " + red + "ERROR\x1b[0m boom ERROR\n"},
{"[warning] disk\n", "WARN", "[" + yellow + "warning\x1b[0m] disk\n"},
{"terror_x ERR:1\n", "ERROR", "terror_x " + red + "ERR\x1b[0m:1\n"},
{"INFOS informal\n", "INFO", "INFOS informal\n"},
{"ERROR without level\n", "", "ERROR without level\n"},
} {
if got := string(paintLevel(p, []byte(c.in), c.level)); got != c.want {
t.Errorf("%q %s: got %q, want %q", c.in, c.level, got, c.want)
}
}
}