25 lines
583 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|