package router import "testing" func TestIsTransientComplaint(t *testing.T) { for _, tc := range []struct { text string want bool }{ // The two rows from the QA run that named this bug. {"сеть какая-то медленная", true}, {"интернет не работает", true}, {"вайфай тормозит", true}, {"сервер завис", true}, {"the wifi is slow", true}, // An instruction wins: he asked for it to be written down. {"запомни что интернет не работает", false}, {"запиши что сеть медленная", false}, // About him, so it stays a fact even when it sounds like a complaint. {"я сломал руку", false}, {"мне медленно думается", false}, // Ordinary captures must not be touched. {"поужинал", false}, {"выпил воды", false}, {"машина на парковке", false}, {"", false}, } { if got := IsTransientComplaint(tc.text); got != tc.want { t.Errorf("IsTransientComplaint(%q) = %v, want %v", tc.text, got, tc.want) } } } // TestComplaintPrefixCollisions — what the prefix list got wrong and the // dictionary does not (Vikunja #528). Each of these contains a word that starts // with one of the old stems and is a different word. func TestComplaintPrefixCollisions(t *testing.T) { for _, s := range []string{ // "лаг" matched "лагерь". "детский лагерь под москвой", // "падает" was literal, but "падеж" and "падение" start on "пад". "падение цен на квартиры", // "отвал" matched "отвальная". "отвальная в пятницу", } { if IsTransientComplaint(s) { t.Errorf("IsTransientComplaint(%q) = true, want false", s) } } // And the real complaints still read as complaints, in the inflections the // prefixes were there to cover. for _, s := range []string{ "сеть какая-то медленная", "интернет не работает", "nextcloud тормозит", "диск сдохнет скоро", "сервис не открывается", } { if !IsTransientComplaint(s) { t.Errorf("IsTransientComplaint(%q) = false, want true", s) } } }