diff --git a/internal/router/agendaq_test.go b/internal/router/agendaq_test.go index 2421ee0..4781d59 100644 --- a/internal/router/agendaq_test.go +++ b/internal/router/agendaq_test.go @@ -39,3 +39,28 @@ func TestIsAgendaQuestionSeparatesHisDayFromTheWorld(t *testing.T) { } } } + +// One hand-written utterance per agenda grammar, keyed by name. Asserting that +// the grammars pass IsAgendaQuestion would be true by construction, since the +// first arm is the loop over them. This asserts something else: that each +// grammar still matches the case its own comment gives, and that the set of +// grammars has not grown a member nobody wrote an example for. +func TestEachAgendaGrammarStillMatchesItsOwnExample(t *testing.T) { + examples := map[string]string{ + "calendar-query": "что в календаре на завтра", + "agenda-query": "что у меня сегодня", + "plan-day-query": "какие планы на завтра", + "rest-of-day-query": "что дальше?", + "event-time-query": "когда планёрка", + } + for _, g := range AgendaQueryGrammars() { + u, ok := examples[g.Name] + if !ok { + t.Errorf("agenda grammar %q has no example here — add one", g.Name) + continue + } + if !g.Pattern.MatchString(u) { + t.Errorf("grammar %q no longer matches %q", g.Name, u) + } + } +}