unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob e256c10ac47a8f370cd42e95eb0bcafbd20b4845 4478 bytes (raw)
name: test/T470-missing-headers.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
 
#!/usr/bin/env bash
test_description='messages with missing headers'
. ./test-lib.sh || exit 1

# Notmuch requires at least one of from, subject, or to or it will
# ignore the file.  Generate two messages so that together they cover
# all possible missing headers.  We also give one of the messages a
# date to ensure stable result ordering.

cat <<EOF > "${MAIL_DIR}/msg-2"
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Fri, 05 Jan 2001 15:43:57 +0000

Body
EOF

cat <<EOF > "${MAIL_DIR}/msg-1"
From: Notmuch Test Suite <test_suite@notmuchmail.org>

Body
EOF

NOTMUCH_NEW

test_begin_subtest "Search: text"
output=$(notmuch search '*' | notmuch_search_sanitize)
test_expect_equal "$output" "\
thread:XXX   2001-01-05 [1/1] (null);  (inbox unread)
thread:XXX   1970-01-01 [1/1] Notmuch Test Suite;  (inbox unread)"

test_begin_subtest "Search: json"
output=$(notmuch search --format=json '*' | notmuch_search_sanitize)
test_expect_equal_json "$output" '
[
    {
        "authors": "",
        "date_relative": "2001-01-05",
        "matched": 1,
        "subject": "",
        "tags": [
            "inbox",
            "unread"
        ],
        "thread": "XXX",
        "timestamp": 978709437,
        "total": 1,
        "query": ["id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161", null]
    },
    {
        "authors": "Notmuch Test Suite",
        "date_relative": "1970-01-01",
        "matched": 1,
        "subject": "",
        "tags": [
            "inbox",
            "unread"
        ],
        "thread": "XXX",
        "timestamp": 0,
        "total": 1,
        "query": ["id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334", null]
    }
]'

test_begin_subtest "Show: text"
output=$(notmuch show '*' | notmuch_show_sanitize)
test_expect_equal "$output" "\
\fmessage{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-2
\fheader{
 (2001-01-05) (inbox unread)
Subject: (null)
From: (null)
To: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Fri, 05 Jan 2001 15:43:57 +0000
\fheader}
\fbody{
\fpart{ ID: 1, Content-type: text/plain
Body
\fpart}
\fbody}
\fmessage}
\fmessage{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-1
\fheader{
Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)
Subject: (null)
From: Notmuch Test Suite <test_suite@notmuchmail.org>
Date: Thu, 01 Jan 1970 00:00:00 +0000
\fheader}
\fbody{
\fpart{ ID: 1, Content-type: text/plain
Body
\fpart}
\fbody}
\fmessage}"

test_begin_subtest "Show: json"
output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)
expected=$(notmuch_json_show_sanitize <<EOF
[
    [
        [
            {
                "body": [
                    {
                        "content": "Body\n",
                        "content-type": "text/plain",
                        "id": 1
                    }
                ],
                "date_relative": "2001-01-05",
                "excluded": false,
                "filename": "YYYYY",
                "headers": {
                    "Date": "Fri, 05 Jan 2001 15:43:57 +0000",
                    "From": "",
                    "Subject": "",
                    "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
                },
                "id": "XXXXX",
                "match": true,
                "tags": [
                    "inbox",
                    "unread"
                ],
                "timestamp": 978709437
            },
            []
        ]
    ],
    [
        [
            {
                "body": [
                    {
                        "content": "Body\n",
                        "content-type": "text/plain",
                        "id": 1
                    }
                ],
                "date_relative": "1970-01-01",
                "excluded": false,
                "filename": "YYYYY",
                "headers": {
                    "Date": "Thu, 01 Jan 1970 00:00:00 +0000",
                    "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
                    "Subject": ""
                },
                "id": "XXXXX",
                "match": true,
                "tags": [
                    "inbox",
                    "unread"
                ],
                "timestamp": 0
            },
            []
        ]
    ]
]
EOF
)
test_expect_equal_json "$output" "$expected"

test_done

debug log:

solving e256c10ac47a ...
found e256c10ac47a in https://yhetil.org/notmuch.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).