]> git.notmuchmail.org Git - notmuch/blobdiff - test/T190-multipart.sh
cli/show: list all filenames of a message in the formatted output
[notmuch] / test / T190-multipart.sh
index 85cbf672da89f0c72ffa1b67f597ed47422029b4..18eb7b839ac01c02f0d9fd9d55dca23c0d5371fe 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="output of multipart message"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 cat <<EOF > embedded_message
 From: Carl Worth <cworth@cworth.org>
@@ -104,6 +104,30 @@ Content-Transfer-Encoding: base64
 7w0K
 --==-=-=--
 EOF
+
+cat <<EOF > content_types
+From: Todd <todd@example.com>
+To: todd@example.com
+Subject: odd content types
+Date: Mon, 12 Jan 2014 18:12:32 +0000
+User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
+Message-ID: <KfjfO2WJBw2hrV2p0gjT@example.com>
+MIME-Version: 1.0
+Content-Type: multipart/alternative; boundary="==-=-=="
+
+--==-=-==
+Content-Type: application/unique_identifier
+
+<p>This is an embedded message, with a multipart/alternative part.</p>
+
+--==-=-==
+Content-Type: text/some_other_identifier
+
+This is an embedded message, with a multipart/alternative part.
+
+--==-=-==--
+EOF
+cat content_types >> ${MAIL_DIR}/odd_content_type
 notmuch new > /dev/null
 
 test_begin_subtest "--format=text --part=0, full message"
@@ -321,7 +345,7 @@ test_expect_success \
 test_begin_subtest "--format=json --part=0, full message"
 notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
 cat <<EOF >EXPECTED
-{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
+{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": ["${MAIL_DIR}/multipart"], "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
 {"id": 1, "content-type": "multipart/signed", "content": [
 {"id": 2, "content-type": "multipart/mixed", "content": [
 {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
@@ -603,7 +627,7 @@ notmuch_json_show_sanitize <<EOF >EXPECTED
  "original": {"id": "XXXXX",
  "match": false,
  "excluded": false,
- "filename": "YYYYY",
+ "filename": ["YYYYY"],
  "timestamp": 978709437,
  "date_relative": "2001-01-05",
  "tags": ["attachment","inbox","signed","unread"],
@@ -691,7 +715,7 @@ cat_expected_head ()
         cat <<EOF
 [[[{"id": "htmlmessage", "match":true, "excluded": false, "date_relative":"2000-01-01",
    "timestamp": 946684800,
-   "filename": "${MAIL_DIR}/include-html",
+   "filename": ["${MAIL_DIR}/include-html"],
    "tags": ["inbox", "unread"],
    "headers": { "Date": "Sat, 01 Jan 2000 00:00:00 +0000", "From": "A <a@example.com>",
                 "Subject": "html message", "To": "B <b@example.com>"},
@@ -727,4 +751,68 @@ test_begin_subtest "html parts included"
 notmuch show --format=json --include-html id:htmlmessage > OUTPUT
 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"
 
+test_begin_subtest "indexes mime-type #1"
+output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2014-01-12 [1/1] Todd; odd content types (inbox unread)"
+
+test_begin_subtest "indexes mime-type #2"
+output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2014-01-12 [1/1] Todd; odd content types (inbox unread)"
+
+test_begin_subtest "indexes mime-type #3"
+output=$(notmuch search from:todd and mimetype:multipart/alternative | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2014-01-12 [1/1] Todd; odd content types (inbox unread)"
+
+test_begin_subtest "case of Content-Disposition doesn't matter for indexing"
+cat <<EOF > ${MAIL_DIR}/content-disposition
+Return-path: <david@tethera.net>
+Envelope-to: david@tethera.net
+Delivery-date: Sun, 04 Oct 2015 09:16:03 -0300
+Received: from gitolite.debian.net ([87.98.215.224])
+       by yantan.tethera.net with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
+       (Exim 4.80)
+       (envelope-from <david@tethera.net>)
+       id 1ZiiCx-0007iz-RK
+       for david@tethera.net; Sun, 04 Oct 2015 09:16:03 -0300
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
+       (envelope-from <david@tethera.net>)
+       id 1ZiiC8-0002Rz-Uf; Sun, 04 Oct 2015 12:15:12 +0000
+Received: (nullmailer pid 28621 invoked by uid 1000); Sun, 04 Oct 2015
+ 12:14:53 -0000
+From: David Bremner <david@tethera.net>
+To: David Bremner <david@tethera.net>
+Subject: test attachment
+User-Agent: Notmuch/0.20.2+93~g33c8777 (http://notmuchmail.org) Emacs/24.5.1
+ (x86_64-pc-linux-gnu)
+Date: Sun, 04 Oct 2015 09:14:53 -0300
+Message-ID: <87io6m96f6.fsf@zancas.localnet>
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="=-=-="
+
+--=-=-=
+Content-Type: text/plain
+Content-Disposition: ATTACHMENT; filename=hello.txt
+Content-Description: this is a very exciting file
+
+hello
+
+--=-=-=
+Content-Type: text/plain
+
+
+world
+
+--=-=-=--
+
+EOF
+NOTMUCH_NEW
+
+cat <<EOF > EXPECTED
+attachment
+inbox
+unread
+EOF
+
+notmuch search --output=tags id:87io6m96f6.fsf@zancas.localnet > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
 test_done