Files
code-utils/holidays_test.go
李琦 e71ce451ff 模块介绍 / 今日规划 / 下班日报 / 团队摘要 生成成功后没有上报,也几乎不写「AI」日志。
流结束时的 usage 用了非阻塞发送,通道一满就被丢掉;很多服务商默认还不在流里带 usage。
现在每次真正打到模型的调用都会:

在本地日志(分类 AI,消息 AI 调用完成)写下 scene / prompt / completion / cached
登录后同步上报到后台日汇总
2026-08-17 14:00:47 +08:00

63 lines
1.7 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"strings"
"testing"
"time"
)
func TestUpcomingHolidaysNationalDay2026(t *testing.T) {
now := time.Date(2026, 8, 17, 12, 0, 0, 0, time.Local)
list := upcomingHolidays(now, 6)
var nd *holidayItem
for i := range list {
if list[i].zh == "国庆节" {
nd = &list[i]
break
}
}
if nd == nil {
t.Fatal("2026-08 起 6 个月内应包含国庆节")
}
if nd.day.Format("2006-01-02") != "2026-10-01" {
t.Fatalf("国庆正日 got %s", nd.day.Format("2006-01-02"))
}
if nd.offStart.Format("2006-01-02") != "2026-10-01" || nd.offEnd.Format("2006-01-02") != "2026-10-07" {
t.Fatalf("国庆放假区间 got %s%s", nd.offStart.Format("2006-01-02"), nd.offEnd.Format("2006-01-02"))
}
}
func TestUpcomingHolidaysMidAutumnQixi2026(t *testing.T) {
now := time.Date(2026, 8, 17, 12, 0, 0, 0, time.Local)
got := map[string]string{}
for _, h := range upcomingHolidays(now, 6) {
got[h.zh] = h.day.Format("2006-01-02")
}
want := map[string]string{
"七夕": "2026-08-19",
"中秋节": "2026-09-25",
"重阳节": "2026-10-18",
"元旦": "2027-01-01",
"春节": "2027-02-06",
}
for name, day := range want {
if got[name] != day {
t.Errorf("%s: got %q want %s", name, got[name], day)
}
}
}
func TestFormatHolidayBlockUsesTableDates(t *testing.T) {
now := time.Date(2026, 8, 17, 12, 0, 0, 0, time.Local)
zh := formatHolidayBlock(now, false)
for _, s := range []string{"国庆节", "2026-10-01", "2026-10-07", "中秋节", "2026-09-25", "七夕", "2026-08-19"} {
if !strings.Contains(zh, s) {
t.Errorf("中文节日块缺少 %q\n%s", s, zh)
}
}
en := formatHolidayBlock(now, true)
if !strings.Contains(en, "National Day") || !strings.Contains(en, "2026-10-01") {
t.Errorf("英文节日块缺少国庆\n%s", en)
}
}