]> git.cworth.org Git - obsolete/notmuch-old/blob - test/missing-headers
test: add tests for insert
[obsolete/notmuch-old] / 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 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     },
48     {
49         "authors": "Notmuch Test Suite",
50         "date_relative": "1970-01-01",
51         "matched": 1,
52         "subject": "",
53         "tags": [
54             "inbox",
55             "unread"
56         ],
57         "thread": "XXX",
58         "timestamp": 0,
59         "total": 1
60     }
61 ]'
62
63 test_begin_subtest "Show: text"
64 output=$(notmuch show '*' | notmuch_show_sanitize)
65 test_expect_equal "$output" "\
66 \fmessage{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-2
67 \fheader{
68  (2001-01-05) (inbox unread)
69 Subject: (null)
70 From: (null)
71 To: Notmuch Test Suite <test_suite@notmuchmail.org>
72 Date: Fri, 05 Jan 2001 15:43:57 +0000
73 \fheader}
74 \fbody{
75 \fpart{ ID: 1, Content-type: text/plain
76 Body
77 \fpart}
78 \fbody}
79 \fmessage}
80 \fmessage{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-1
81 \fheader{
82 Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)
83 Subject: (null)
84 From: Notmuch Test Suite <test_suite@notmuchmail.org>
85 Date: Thu, 01 Jan 1970 00:00:00 +0000
86 \fheader}
87 \fbody{
88 \fpart{ ID: 1, Content-type: text/plain
89 Body
90 \fpart}
91 \fbody}
92 \fmessage}"
93
94 test_begin_subtest "Show: json"
95 output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)
96 test_expect_equal_json "$output" '
97 [
98     [
99         [
100             {
101                 "body": [
102                     {
103                         "content": "Body\n",
104                         "content-type": "text/plain",
105                         "id": 1
106                     }
107                 ],
108                 "date_relative": "2001-01-05",
109                 "excluded": false,
110                 "filename": "YYYYY",
111                 "headers": {
112                     "Date": "Fri, 05 Jan 2001 15:43:57 +0000",
113                     "From": "",
114                     "Subject": "",
115                     "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
116                 },
117                 "id": "XXXXX",
118                 "match": true,
119                 "tags": [
120                     "inbox",
121                     "unread"
122                 ],
123                 "timestamp": 978709437
124             },
125             []
126         ]
127     ],
128     [
129         [
130             {
131                 "body": [
132                     {
133                         "content": "Body\n",
134                         "content-type": "text/plain",
135                         "id": 1
136                     }
137                 ],
138                 "date_relative": "1970-01-01",
139                 "excluded": false,
140                 "filename": "YYYYY",
141                 "headers": {
142                     "Date": "Thu, 01 Jan 1970 00:00:00 +0000",
143                     "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
144                     "Subject": ""
145                 },
146                 "id": "XXXXX",
147                 "match": true,
148                 "tags": [
149                     "inbox",
150                     "unread"
151                 ],
152                 "timestamp": 0
153             },
154             []
155         ]
156     ]
157 ]'
158
159
160 test_done