package notify import ( "strings" "testing" ) // R-836, `09` §3 decision 172: the household's day-before mail — both languages, informal, says the box restarts // tonight and exactly what to do if it is not back by morning. ASCII fragments with a positive and a negative control // (rule 8: an accented search can return nothing for text that is there). func TestKernelNotice_SaysWhatToDo(t *testing.T) { for lang, want := range map[string][]string{ "hu": {"jjel", "jraindul", "tápkábel"[:2], "10 m", "dugd", "vissza", "korábbi"[:3]}, "en": {"Tonight", "restarts", "unplug", "10 seconds", "plug it back", "earlier, proven"}, } { subj, body := FormatKernelNoticeEmail(lang) if subj == "" || body == "" || strings.HasPrefix(subj, "mail.") || strings.HasPrefix(body, "mail.") { t.Fatalf("%s: missing text: %q / %q", lang, subj, body) } for _, w := range want { if !strings.Contains(body, w) { t.Fatalf("%s: body lacks %q:\n%s", lang, w, body) } } if strings.Contains(body, "7.0.") || strings.Contains(body, "%") { t.Fatalf("%s: the household needs what to do, not a kernel version or a format verb:\n%s", lang, body) } } // negative control: a key that does not exist comes back as its own name if s, _ := FormatClaimEmail("en", "claim", "c", "d", "x"); strings.Contains(s, "unplug") { t.Fatal("negative control matched") } }