Files
wehub-resource-sync 36b3af2e3d
PR Check / Code Quality: Format (push) Failing after 1s
PR Check / Code Quality: Lint (darwin) (push) Failing after 0s
PR Check / Code Quality: Lint (freebsd) (push) Failing after 1s
PR Check / Code Quality: Lint (windows) (push) Failing after 1s
PR Check / Code Quality: Lint (linux) (push) Failing after 1s
PR Check / Security: Vulnerability Scan (push) Failing after 0s
Update Documentation / update-docs (push) Failing after 2s
PR Check / Code Quality: Vendor (push) Failing after 1s
PR Check / Code Quality: Coverage (push) Failing after 0s
PR Check / Tests: Unit (macos-latest) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04-arm) (push) Has been cancelled
PR Check / Tests: Unit (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:22:06 +08:00

35 lines
815 B
Go

package output
import (
"testing"
"time"
)
func TestFormatStartedAt(t *testing.T) {
if rel, abs := FormatStartedAt(time.Time{}); rel != "unknown" || abs != "" {
t.Errorf("zero time = (%q, %q), want (\"unknown\", \"\")", rel, abs)
}
now := time.Now()
cases := []struct {
ago time.Duration
want string
}{
{30 * time.Second, "just now"},
{5 * time.Minute, "5 min ago"},
{90 * time.Minute, "1 hour ago"},
{5 * time.Hour, "5 hours ago"},
{30 * time.Hour, "1 day ago"},
{72 * time.Hour, "3 days ago"},
}
for _, tc := range cases {
rel, abs := FormatStartedAt(now.Add(-tc.ago))
if rel != tc.want {
t.Errorf("FormatStartedAt(-%v) rel = %q, want %q", tc.ago, rel, tc.want)
}
if abs == "" {
t.Errorf("FormatStartedAt(-%v) absolute timestamp should not be empty", tc.ago)
}
}
}