feat: add progressive Eino examples and unify weather provider

This commit is contained in:
loveuer committed 2026-11-18 16:29:00 +08:00
1 parent 73f6f0901e
commit 1373f0903f
18 files changed
+893 -380

No files matched your search

+8 -2
View File
@@ -21,6 +21,7 @@ func TestForecastDates(t *testing.T) {
name, start, end, wantEnd string
invalid bool
}{
{name: "默认今天", wantEnd: "2027-01-01"},
{name: "单日", start: "2027-01-02", wantEnd: "2027-01-02"},
{name: "整个窗口", start: "2027-01-01", end: "2027-01-16", wantEnd: "2027-01-16"},
{name: "缺少开始日期", end: "2027-01-02", invalid: true},
@@ -39,7 +40,11 @@ func TestForecastDates(t *testing.T) {
}
return
}
if err != nil || start.Format(time.DateOnly) != tt.start || end.Format(time.DateOnly) != tt.wantEnd {
wantStart := tt.start
if wantStart == "" {
wantStart = "2027-01-01"
}
if err != nil || start.Format(time.DateOnly) != wantStart || end.Format(time.DateOnly) != tt.wantEnd {
t.Fatalf("日期范围 = %s 至 %s,错误 = %v", start, end, err)
}
})
@@ -111,8 +116,9 @@ func TestForecastInvalidArguments(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) { calls++ }))
defer server.Close()
weather := NewWeather()
weather.baseURL, weather.geocodingURL = server.URL, server.URL
weather.geocodingURL = server.URL
for _, args := range []string{
`{`, `{}`, `null`, `{"location":" "}`, `{"location":123}`,
`{"location":"北京","end_date":"2026-11-20"}`,
`{"location":"北京","start_date":"明天"}`,
`{"location":"北京","start_date":"2000-01-01"}`,