支持工具链
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package timeagent
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestResolveBuildsCalendarRanges(t *testing.T) {
|
||||
loc := time.FixedZone("CST", 8*60*60)
|
||||
ctx := Resolve(time.Date(2026, 6, 10, 13, 14, 15, 0, loc))
|
||||
if got := FormatSQLRange(ctx.Today); got != "start=2026-06-10 00:00:00, end_exclusive=2026-06-11 00:00:00" {
|
||||
t.Fatalf("today = %s", got)
|
||||
}
|
||||
if got := FormatSQLRange(ctx.ThisMonth); got != "start=2026-06-01 00:00:00, end_exclusive=2026-07-01 00:00:00" {
|
||||
t.Fatalf("this month = %s", got)
|
||||
}
|
||||
if got := FormatSQLRange(ctx.ThisWeek); got != "start=2026-06-08 00:00:00, end_exclusive=2026-06-15 00:00:00" {
|
||||
t.Fatalf("this week = %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildContextIncludesSQLHints(t *testing.T) {
|
||||
ctx := Resolve(time.Date(2026, 6, 10, 13, 14, 15, 0, time.UTC))
|
||||
text := BuildContext(ctx, "需要日期范围")
|
||||
for _, want := range []string{"时间工具结果", "本月", "start=", "end_exclusive=", "半开区间", "需要日期范围"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("context missing %q:\n%s", want, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user