39 lines
852 B
Go
39 lines
852 B
Go
package output
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestParseJobTime_RFC3339(t *testing.T) {
|
|
got, err := parseJobTime("2026-04-08T17:00:10.159507024+08:00")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.Year() != 2026 || got.Month() != time.April || got.Day() != 8 {
|
|
t.Errorf("wrong date: %v", got)
|
|
}
|
|
}
|
|
|
|
func TestParseJobTime_SpaceFormat(t *testing.T) {
|
|
got, err := parseJobTime("2026-04-08 17:00:10")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.Hour() != 17 {
|
|
t.Errorf("wrong hour: %v", got)
|
|
}
|
|
}
|
|
|
|
func TestParseJobTime_Empty(t *testing.T) {
|
|
if _, err := parseJobTime(""); err == nil {
|
|
t.Error("expected error for empty string")
|
|
}
|
|
}
|
|
|
|
func TestFormatJobTime(t *testing.T) {
|
|
tm := time.Date(2026, time.April, 8, 17, 0, 10, 0, time.UTC)
|
|
if got := formatJobTime(tm); got != "Apr 08 17:00" {
|
|
t.Errorf("got %q want %q", got, "Apr 08 17:00")
|
|
}
|
|
}
|