fix(diary): skip HideOnTTY records only on a terminal console, also with forced color (IN-01, quick-261028-rqd)

This commit is contained in:
Jakub Zych
2026-10-28 20:41:07 +01:00
parent f91d70d05e
commit 3520d5d480
8 changed files with 75 additions and 23 deletions

View File

@@ -174,7 +174,9 @@ func TestServeRecords(t *testing.T) {
t.Errorf("admin warning record missing:\n%s", logs.String())
}
// HideOnTTY: hidden on a styled console, kept in the daily file.
// HideOnTTY: hidden only on a terminal console (diary's
// TestConsoleHideOnTTYTerminal), kept in the daily file and, since
// IN-01, on a styled console that is not a terminal (forced color).
root := t.TempDir()
cfg, err := compass.Open(compass.Options{Dir: t.TempDir(), Environ: []string{"SUMMER_LOG__CHANNELS__DAILY__LEVEL=info"}})
if err != nil {
@@ -187,11 +189,12 @@ func TestServeRecords(t *testing.T) {
t.Fatal(err)
}
logSummary(diary.HideOnTTY(context.Background()), serveLog, f)
if strings.Contains(console.String(), summaryMessage) || strings.Contains(console.String(), "listening on") {
t.Errorf("styled console shows the hidden records:\n%s", console.String())
if !strings.Contains(console.String(), summaryMessage) || !strings.Contains(console.String(), "listening on") {
t.Errorf("forced-color console off a terminal dropped the HideOnTTY records:\n%s", console.String())
}
before := len(console.String())
logSummary(context.Background(), serveLog, f)
if !strings.Contains(console.String(), "listening on :8096") {
if !strings.Contains(console.String()[before:], "listening on :8096") {
t.Errorf("styled console lacks the records logged without HideOnTTY:\n%s", console.String())
}
if err := diary.Close(); err != nil {