]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
testsuite: simple test for text formatting
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 4 Nov 2021 10:48:58 +0000 (11:48 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 4 Nov 2021 10:48:58 +0000 (11:48 +0100)
tests/mlmmj.c

index 6a6ed3eb06efdcbb6670c4af72b3683c3659ef3c..67ddfd98bcd385bbfeebd351d6cc36c02fd8155e 100644 (file)
@@ -168,6 +168,30 @@ ATF_TC_BODY(mlmmj_list, tc)
        fclose(f);
 }
 
+static const char *formatted_text1 =
+"Subject: =?utf-8?q?Welcome_to_test=40test?=\n"
+"From: test+help@test\n"
+"To: john@doe.net\n"
+"Message-ID: <1636022023-16598-mlmmj-39117dfa@test>\n"
+"Date: Thu, 04 Nov 2021 10:33:43 +0000\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"\n"
+"\n"
+"Thank you for your request to join us. You have now been added to the\n"
+"normal version of the list.\n"
+"\n"
+"The email address you are subscribed with is <john@doe.net>.\n"
+"\n"
+"If you ever wish to unsubscribe, send a message to <test+unsubscribe@test>\n"
+"using this email address. The subject and the body of the message can be\n"
+"anything. You will then receive confirmation or further instructions.\n"
+"\n"
+"For other information and help about this list, send a message to\n"
+"<test+help@test>.\n"
+"\n";
+
 ATF_TC_BODY(open_text, tc)
 {
        struct mlmmj_list list;
@@ -180,6 +204,19 @@ ATF_TC_BODY(open_text, tc)
        list.entext = SRCDIR "/listtexts/en";
        text *txt = open_text(&list, "finish", "sub", "request", "normal", "sub-confirm");
        ATF_CHECK(txt != NULL);
+       register_unformatted(txt, "subaddr", "john@doe.net");
+       char *qname = prepstdreply(txt, &list, "$helpaddr$", "john@doe.net", NULL);
+       if (!atf_utils_grep_file("^To: john@doe.net", qname) ||
+           !atf_utils_grep_file("^The email address .*john@doe.net.*", qname) ||
+           !atf_utils_grep_file("^Subject: .*Welcome_to_test", qname)) {
+               printf("===== generated ====\n");
+               atf_utils_cat_file(qname, "");
+               printf("===== expected ====\n");
+               printf("%s", formatted_text1);
+               printf("===================\n");
+               atf_tc_fail("Invalid formatted mail");
+       }
+       ATF_CHECK(qname != NULL);
 }
 
 ATF_TP_ADD_TCS(tp)