From 61ea3ce2af8236a858dbb389d2f398a4105ecf35 Mon Sep 17 00:00:00 2001 From: mixeme Date: Wed, 24 Jun 2026 07:52:53 +0300 Subject: [PATCH] app/format_test: add EventLine test cases (T1.4) Cover the compact formatter with three scenarios: - Log file present: shows base name only (not full path) - Log file absent: formats without a log column - Empty trigger: defaults to "Unknown" Co-Authored-By: Claude Sonnet 4.6 --- src/app/format_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/app/format_test.go b/src/app/format_test.go index 3fb3f54..3da9693 100644 --- a/src/app/format_test.go +++ b/src/app/format_test.go @@ -98,3 +98,27 @@ func TestDisplayIndex(t *testing.T) { t.Errorf("DisplayIndex(missing) = %d, want 0", got) } } + +func TestEventLine(t *testing.T) { + withLog := domain.RunRecord{ + Time: "2026-06-19 12:00:00", Trigger: "Schedule", JobName: "Build", + State: "Success", Detail: "ok", LogFile: "/home/user/logs/build-20260619.log", + } + if got, want := EventLine(withLog), "2026-06-19 12:00:00 Schedule Build Success ok build-20260619.log"; got != want { + t.Errorf("EventLine with log = %q, want %q", got, want) + } + + noLog := domain.RunRecord{ + Time: "2026-06-19 12:00:00", Trigger: "Manual", JobName: "Build", + State: "Success", Detail: "ok", + } + if got, want := EventLine(noLog), "2026-06-19 12:00:00 Manual Build Success ok"; got != want { + t.Errorf("EventLine without log = %q, want %q", got, want) + } + + // An empty trigger is shown as "Unknown". + blank := domain.RunRecord{Time: "t", JobName: "J", State: "S", Detail: "d", LogFile: "/path/to/file.log"} + if got, want := EventLine(blank), "t Unknown J S d file.log"; got != want { + t.Errorf("EventLine blank trigger = %q, want %q", got, want) + } +}