Files
past-go/past-go/internal/handler/diary_test.go
T
2026-10-07 09:28:43 +08:00

25 lines
583 B
Go

package handler
import "testing"
func TestDiaryDateOrFallback(t *testing.T) {
tests := []struct {
name string
value any
fallback string
want string
}{
{"missing", nil, "2026-09-19", "2026-09-19"},
{"empty", "", "2026-09-19", "2026-09-19"},
{"whitespace", " ", "2026-09-19", "2026-09-19"},
{"provided", " 2026-09-18 ", "2026-09-19", "2026-09-18"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := diaryDateOrFallback(tt.value, tt.fallback); got != tt.want {
t.Fatalf("got %q, want %q", got, tt.want)
}
})
}
}