Log errors in red in summary

This commit is contained in:
2025-11-20 15:41:36 +01:00
parent 88ef93e9af
commit cb53596c46
2 changed files with 20 additions and 1 deletions

View File

@@ -48,7 +48,7 @@ func (r operationRecord) summaryLine() (string, bool) {
status := "OK" status := "OK"
if r.err != nil { if r.err != nil {
status = fmt.Sprintf("FAIL: %v", r.err) status = fmt.Sprintf("%sFAIL%s: %v", BRed, Reset, r.err)
} else if r.dryRun { } else if r.dryRun {
status = "DRY-RUN" status = "DRY-RUN"
} }

19
filesystem_test.go Normal file
View File

@@ -0,0 +1,19 @@
package main
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSummaryLineMarksFailuresInRed(t *testing.T) {
fs := NewRealFileSystem()
fs.RecordLinkAttempt(opSymlink, "/tmp/source", "/tmp/target", fmt.Errorf("boom"), false)
lines := fs.SummaryLines()
assert.Equal(t, 1, len(lines))
assert.Contains(t, lines[0], BRed+"FAIL"+Reset)
assert.Contains(t, lines[0], "boom")
}