]> git.notmuchmail.org Git - notmuch/blob - test/missing-headers
e79f92278a28bc0dfe7ef0b4908d2919060e6b11
[notmuch] / test / missing-headers
1 #!/usr/bin/env bash
2 test_description='messages with missing headers'
3 . ./test-lib.sh
4
5 # Notmuch requires at least one of from, subject, or to or it will
6 # ignore the file.  Generate two messages so that together they cover
7 # all possible missing headers.  We also give one of the messages a
8 # date to ensure stable result ordering.
9
10 cat <<EOF > "${MAIL_DIR}/msg-2"
11 To: Notmuch Test Suite <test_suite@notmuchmail.org>
12 Date: Fri, 05 Jan 2001 15:43:57 +0000
13
14 Body
15 EOF
16
17 cat <<EOF > "${MAIL_DIR}/msg-1"
18 From: Notmuch Test Suite <test_suite@notmuchmail.org>
19
20 Body
21 EOF
22
23 NOTMUCH_NEW
24
25 test_begin_subtest "Search: text"
26 output=$(notmuch search '*' | notmuch_search_sanitize)
27 test_expect_equal "$output" "\
28 thread:XXX   2001-01-05 [1/1] (null);  (inbox unread)
29 thread:XXX   1970-01-01 [1/1] Notmuch Test Suite;  (inbox unread)"
30
31 test_begin_subtest "Search: json"
32 test_subtest_known_broken
33 output=$(notmuch search --format=json '*' | notmuch_search_sanitize)
34 test_expect_equal_json "$output" '
35 [
36     {
37         "authors": "",
38         "date_relative": "2001-01-05",
39         "matched": 1,
40         "subject": "",
41         "tags": [
42             "inbox",
43             "unread"
44         ],
45         "thread": "XXX",
46         "timestamp": 978709437,
47         "total": 1
48     },
49     {
50         "authors": "Notmuch Test Suite",
51         "date_relative": "1970-01-01",
52         "matched": 1,
53         "subject": "",
54         "tags": [
55             "inbox",
56             "unread"
57         ],
58         "thread": "XXX",
59         "timestamp": 0,
60         "total": 1
61     }
62 ]'
63
64 test_begin_subtest "Show: text"
65 output=$(notmuch show '*' | notmuch_show_sanitize)
66 test_expect_equal "$output" "\
67 \fmessage{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-2
68 \fheader{
69  (2001-01-05) (inbox unread)
70 Subject: (null)
71 From: (null)
72 To: Notmuch Test Suite <test_suite@notmuchmail.org>
73 Date: Fri, 05 Jan 2001 15:43:57 +0000
74 \fheader}
75 \fbody{
76 \fpart{ ID: 1, Content-type: text/plain
77 Body
78 \fpart}
79 \fbody}
80 \fmessage}
81 \fmessage{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-1
82 \fheader{
83 Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)
84 Subject: (null)
85 From: Notmuch Test Suite <test_suite@notmuchmail.org>
86 Date: Thu, 01 Jan 1970 00:00:00 +0000
87 \fheader}
88 \fbody{
89 \fpart{ ID: 1, Content-type: text/plain
90 Body
91 \fpart}
92 \fbody}
93 \fmessage}"
94
95 test_begin_subtest "Show: json"
96 test_subtest_known_broken
97 output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)
98 test_expect_equal_json "$output" '
99 [
100     [
101         [
102             {
103                 "body": [
104                     {
105                         "content": "Body\n",
106                         "content-type": "text/plain",
107                         "id": 1
108                     }
109                 ],
110                 "date_relative": "2001-01-05",
111                 "excluded": false,
112                 "filename": "YYYYY",
113                 "headers": {
114                     "Date": "Fri, 05 Jan 2001 15:43:57 +0000",
115                     "From": "",
116                     "Subject": "",
117                     "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
118                 },
119                 "id": "XXXXX",
120                 "match": true,
121                 "tags": [
122                     "inbox",
123                     "unread"
124                 ],
125                 "timestamp": 978709437
126             },
127             []
128         ]
129     ],
130     [
131         [
132             {
133                 "body": [
134                     {
135                         "content": "Body\n",
136                         "content-type": "text/plain",
137                         "id": 1
138                     }
139                 ],
140                 "date_relative": "1970-01-01",
141                 "excluded": false,
142                 "filename": "YYYYY",
143                 "headers": {
144                     "Date": "Thu, 01 Jan 1970 00:00:00 +0000",
145                     "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
146                     "Subject": ""
147                 },
148                 "id": "XXXXX",
149                 "match": true,
150                 "tags": [
151                     "inbox",
152                     "unread"
153                 ],
154                 "timestamp": 0
155             },
156             []
157         ]
158     ]
159 ]'
160
161
162 test_done