package router import "testing" func TestMavenHelpGrammarKeepsFeatureHowToLocal(t *testing.T) { g := MavenHelpGrammar() for _, testCase := range []struct { utterance string topic HelpTopic }{ {"как отменить напоминание про молоко?", HelpReminderCancel}, {"как удалить будильник на девять?", HelpReminderCancel}, {"как отменить задачу настроить бэкапы?", HelpTaskDrop}, {"how do I remove a task?", HelpTaskDrop}, {"можно ли отменить напоминание?", HelpReminderCancel}, {"can I cancel a reminder?", HelpReminderCancel}, {"could I cancel a task?", HelpTaskDrop}, } { decision, matched, accepted := g.Evaluate(testCase.utterance) if !matched || !accepted || decision.Intent != IntentQuery || decision.Source != SourceSelf { t.Errorf("%q = %+v, matched=%v accepted=%v; want self query", testCase.utterance, decision, matched, accepted) } if got := LocalHelpTopic(testCase.utterance); got != testCase.topic { t.Errorf("LocalHelpTopic(%q) = %q, want %q", testCase.utterance, got, testCase.topic) } } } func TestMavenHelpGrammarDoesNotStealCommandsOrWorldAdvice(t *testing.T) { g := MavenHelpGrammar() for _, utterance := range []string{ "отмени напоминание про молоко", "убери из задач настроить бэкапы", "как убрать царапину с моего стола?", "как работает напоминание?", "запиши как отменить задачу", "can you cancel a reminder", } { if decision, matched, accepted := g.Evaluate(utterance); matched || accepted { t.Errorf("%q was claimed as %+v", utterance, decision) } } }