修复财务仪表盘日明细

This commit is contained in:
yml2213
2026-06-21 09:44:19 +08:00
parent a5165d17e9
commit 5c67f5c411
3 changed files with 42 additions and 6 deletions
@@ -0,0 +1,25 @@
package adminfinance
import "testing"
func TestDailyDateKey(t *testing.T) {
tests := []struct {
name string
in string
want string
}{
{name: "date only", in: "2026-06-15", want: "2026-06-15"},
{name: "datetime", in: "2026-06-15 00:00:00", want: "2026-06-15"},
{name: "rfc3339", in: "2026-06-15T00:00:00+08:00", want: "2026-06-15"},
{name: "trim spaces", in: " 2026-06-15T00:00:00Z ", want: "2026-06-15"},
{name: "short value", in: "2026-06", want: "2026-06"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := dailyDateKey(tt.in); got != tt.want {
t.Fatalf("dailyDateKey(%q) = %q, want %q", tt.in, got, tt.want)
}
})
}
}