]> git.cworth.org Git - notmuch/blob - test/T470-missing-headers.sh
debian: changelog stanza for 0.28-1
[notmuch] / test / T470-missing-headers.sh
1 #!/usr/bin/env bash
2 test_description='messages with missing headers'
3 . $(dirname "$0")/test-lib.sh || exit 1
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 >/dev/null
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] ;  (inbox unread)
29 thread:XXX   1970-01-01 [1/1] Notmuch Test Suite;  (inbox unread)"
30
31 test_begin_subtest "Search: json"
32 output=$(notmuch search --format=json '*' | notmuch_search_sanitize)
33 test_expect_equal_json "$output" '
34 [
35     {
36         "authors": "",
37         "date_relative": "2001-01-05",
38         "matched": 1,
39         "subject": "",
40         "tags": [
41             "inbox",
42             "unread"
43         ],
44         "thread": "XXX",
45         "timestamp": 978709437,
46         "total": 1,
47         "query": ["id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161", null]
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         "query": ["id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334", null]
62     }
63 ]'
64
65 test_begin_subtest "Show: text"
66 output=$(notmuch show '*' | notmuch_show_sanitize)
67 test_expect_equal "$output" "\
68 \fmessage{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-2
69 \fheader{
70  (2001-01-05) (inbox unread)
71 Subject: (null)
72 From: (null)
73 To: Notmuch Test Suite <test_suite@notmuchmail.org>
74 Date: Fri, 05 Jan 2001 15:43:57 +0000
75 \fheader}
76 \fbody{
77 \fpart{ ID: 1, Content-type: text/plain
78 Body
79 \fpart}
80 \fbody}
81 \fmessage}
82 \fmessage{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-1
83 \fheader{
84 Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)
85 Subject: (null)
86 From: Notmuch Test Suite <test_suite@notmuchmail.org>
87 Date: Thu, 01 Jan 1970 00:00:00 +0000
88 \fheader}
89 \fbody{
90 \fpart{ ID: 1, Content-type: text/plain
91 Body
92 \fpart}
93 \fbody}
94 \fmessage}"
95
96 test_begin_subtest "Show: json"
97 output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)
98 expected=$(notmuch_json_show_sanitize <<EOF
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 EOF
161 )
162 test_expect_equal_json "$output" "$expected"
163
164 test_done