style: formatting for time + colors

This commit is contained in:
2026-03-21 08:24:30 +00:00
parent f50a6b6447
commit f4820d8099
4 changed files with 43 additions and 14 deletions
+21
View File
@@ -5,8 +5,29 @@ import (
"path/filepath"
"strings"
"testing"
"time"
)
func TestFormatElapsed(t *testing.T) {
tests := []struct {
name string
elapsed time.Duration
wantText string
}{
{name: "sub-second", elapsed: 123 * time.Millisecond, wantText: "123 ms"},
{name: "boundary", elapsed: time.Second, wantText: "1.00 s"},
{name: "multi-second", elapsed: 1534 * time.Millisecond, wantText: "1.53 s"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := formatElapsed(tt.elapsed); got != tt.wantText {
t.Fatalf("formatElapsed(%v) = %q, want %q", tt.elapsed, got, tt.wantText)
}
})
}
}
func TestDiscoverTestScenariosFindsNestedFixturesAndSorts(t *testing.T) {
testDir := filepath.Join(t.TempDir(), "e2e")
writeScenarioFixtures(t, filepath.Join(testDir, "nested", "b"), "echo two\n", "echo two\n")