package router import ( "testing" "time" ) // Russian capture must produce the same keys the loop's care rules read, or a // ru voice test silently writes nothing and the nudges look broken. func TestDefaultFactParserRU(t *testing.T) { p := DefaultFactParser{} cases := []struct { utterance string key string ok bool }{ {"выпил воды", "water", true}, {"попил воду", "water", true}, {"я поел", "meal", true}, {"пообедал", "meal", true}, {"принял душ", "shower", true}, {"сделал перерыв", "break", true}, {"немного отдохнул", "break", true}, {"поспал шесть часов", "sleep", true}, {"перезапусти nginx", "", false}, // an act, not a fact } for _, c := range cases { k, _, ok := p.Parse(c.utterance) if ok != c.ok || k != c.key { t.Errorf("Parse(%q) = (%q, %v), want (%q, %v)", c.utterance, k, ok, c.key, c.ok) } } } func TestParseCalendarDate(t *testing.T) { now := time.Date(2026, 7, 6, 14, 30, 0, 0, time.UTC) cases := []struct { text string want time.Time ok bool }{ {"что у меня сегодня по плану", time.Date(2026, 7, 6, 0, 0, 0, 0, time.UTC), true}, {"что завтра", time.Date(2026, 7, 7, 0, 0, 0, 0, time.UTC), true}, {"планы на сегодня", time.Date(2026, 7, 6, 0, 0, 0, 0, time.UTC), true}, {"расписание на завтра", time.Date(2026, 7, 7, 0, 0, 0, 0, time.UTC), true}, {"what's today", time.Date(2026, 7, 6, 0, 0, 0, 0, time.UTC), true}, {"tomorrow plans", time.Date(2026, 7, 7, 0, 0, 0, 0, time.UTC), true}, {"какая погода", time.Time{}, false}, {"сколько времени", time.Time{}, false}, {"", time.Time{}, false}, } for _, c := range cases { got, ok := ParseCalendarDate(c.text, now) if ok != c.ok || !got.Equal(c.want) { t.Errorf("ParseCalendarDate(%q) = %v, %v; want %v, %v", c.text, got, ok, c.want, c.ok) } } }