2012-12-06 22:12:14 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
test_description="--format=sexp output"
|
2017-09-25 22:38:19 +02:00
|
|
|
. $(dirname "$0")/test-lib.sh || exit 1
|
2021-05-23 09:34:43 +02:00
|
|
|
. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
|
2012-12-06 22:12:14 +01:00
|
|
|
|
|
|
|
test_begin_subtest "Show message: sexp"
|
|
|
|
add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc@notmuchmail.org\"" "[reply-to]=\"test_suite+replyto@notmuchmail.org\"" "[body]=\"sexp-show-message\""
|
|
|
|
output=$(notmuch show --format=sexp "sexp-show-message")
|
2019-05-27 00:15:54 +02:00
|
|
|
test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil :filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type \"text/plain\" :content \"sexp-show-message\n\")) :crypto () :headers (:Subject \"sexp-show-subject\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :Bcc \"test_suite+bcc@notmuchmail.org\" :Reply-To \"test_suite+replyto@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\")) ())))"
|
2012-12-06 22:12:14 +01:00
|
|
|
|
|
|
|
# This should be the same output as above.
|
|
|
|
test_begin_subtest "Show message: sexp --body=true"
|
|
|
|
output=$(notmuch show --format=sexp --body=true "sexp-show-message")
|
2019-05-27 00:15:54 +02:00
|
|
|
test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil :filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type \"text/plain\" :content \"sexp-show-message\n\")) :crypto () :headers (:Subject \"sexp-show-subject\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :Bcc \"test_suite+bcc@notmuchmail.org\" :Reply-To \"test_suite+replyto@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\")) ())))"
|
2012-12-06 22:12:14 +01:00
|
|
|
|
|
|
|
test_begin_subtest "Show message: sexp --body=false"
|
|
|
|
output=$(notmuch show --format=sexp --body=false "sexp-show-message")
|
2019-05-27 00:15:54 +02:00
|
|
|
test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil :filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :crypto () :headers (:Subject \"sexp-show-subject\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :Bcc \"test_suite+bcc@notmuchmail.org\" :Reply-To \"test_suite+replyto@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\")) ())))"
|
2012-12-06 22:12:14 +01:00
|
|
|
|
|
|
|
test_begin_subtest "Search message: sexp"
|
|
|
|
add_message "[subject]=\"sexp-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"sexp-search-message\""
|
|
|
|
output=$(notmuch search --format=sexp "sexp-search-message" | notmuch_search_sanitize)
|
2013-10-24 17:19:08 +02:00
|
|
|
test_expect_equal "$output" "((:thread \"0000000000000002\" :timestamp 946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test Suite\" :subject \"sexp-search-subject\" :query (\"id:$gen_msg_id\" nil) :tags (\"inbox\" \"unread\")))"
|
2012-12-06 22:12:14 +01:00
|
|
|
|
|
|
|
test_begin_subtest "Show message: sexp, utf-8"
|
|
|
|
add_message "[subject]=\"sexp-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\""
|
|
|
|
output=$(notmuch show --format=sexp "jsön-show-méssage")
|
2019-05-27 00:15:54 +02:00
|
|
|
test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil :filename (\"${gen_msg_filename}\") :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :body ((:id 1 :content-type \"text/plain\" :content \"jsön-show-méssage\n\")) :crypto () :headers (:Subject \"sexp-show-utf8-body-sübjéct\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\")) ())))"
|
2012-12-06 22:12:14 +01:00
|
|
|
|
2017-08-27 14:50:50 +02:00
|
|
|
test_begin_subtest "Search message: sexp, utf-8"
|
|
|
|
add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
|
|
|
|
output=$(notmuch search --format=sexp "jsön-search-méssage" | notmuch_search_sanitize)
|
|
|
|
test_expect_equal "$output" "((:thread \"0000000000000004\" :timestamp 946728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmuch Test Suite\" :subject \"sexp-search-utf8-body-sübjéct\" :query (\"id:$gen_msg_id\" nil) :tags (\"inbox\" \"unread\")))"
|
|
|
|
|
2012-12-06 22:12:14 +01:00
|
|
|
test_begin_subtest "Show message: sexp, inline attachment filename"
|
|
|
|
subject='sexp-show-inline-attachment-filename'
|
|
|
|
id="sexp-show-inline-attachment-filename@notmuchmail.org"
|
2013-12-14 15:39:54 +01:00
|
|
|
emacs_fcc_message \
|
2012-12-06 22:12:14 +01:00
|
|
|
"$subject" \
|
|
|
|
'This is a test message with inline attachment with a filename' \
|
2017-09-25 22:38:29 +02:00
|
|
|
"(mml-attach-file \"$NOTMUCH_SRCDIR/test/README\" nil nil \"inline\")
|
2012-12-06 22:12:14 +01:00
|
|
|
(message-goto-eoh)
|
|
|
|
(insert \"Message-ID: <$id>\n\")"
|
|
|
|
output=$(notmuch show --format=sexp "id:$id")
|
|
|
|
filename=$(notmuch search --output=files "id:$id")
|
2012-12-15 04:06:45 +01:00
|
|
|
# Get length of README after base64-encoding, minus additional newline.
|
2017-09-25 22:38:29 +02:00
|
|
|
attachment_length=$(( $(base64 $NOTMUCH_SRCDIR/test/README | wc -c) - 1 ))
|
2019-05-27 00:15:54 +02:00
|
|
|
test_expect_equal "$output" "((((:id \"$id\" :match t :excluded nil :filename (\"$filename\") :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :body ((:id 1 :content-type \"multipart/mixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a test message with inline attachment with a filename\") (:id 3 :content-type \"application/octet-stream\" :content-disposition \"inline\" :filename \"README\" :content-transfer-encoding \"base64\" :content-length $attachment_length)))) :crypto () :headers (:Subject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite <test_suite@notmuchmail.org>\" :To \"test_suite@notmuchmail.org\" :Date \"Sat, 01 Jan 2000 12:00:00 +0000\")) ())))"
|
2012-12-06 22:12:14 +01:00
|
|
|
|
2022-01-01 13:01:36 +01:00
|
|
|
test_begin_subtest "show extra headers"
|
|
|
|
add_message "[subject]=\"extra-headers\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[in-reply-to]=\"<parent@notmuch-test-suite>\"" "[body]=\"extra-headers test\""\
|
|
|
|
"[header]=\"Received: from mail.example.com (mail.example.com [1.1.1.1])
|
|
|
|
by mail.notmuchmail.org (some MTA) with ESMTP id 12345678
|
|
|
|
for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)\"" \
|
|
|
|
|
|
|
|
notmuch config set show.extra_headers "in-reply-to;received"
|
|
|
|
notmuch show --format=sexp --body=false id:${gen_msg_id} | \
|
|
|
|
notmuch_dir_sanitize | sed 's/msg-[0-9]*/MSG/g'> OUTPUT
|
|
|
|
cat <<EOF > EXPECTED
|
|
|
|
((((:id "MSG@notmuch-test-suite" :match t :excluded nil :filename ("MAIL_DIR/MSG") :timestamp 946728000 :date_relative "2000-01-01" :tags ("inbox" "unread") :crypto () :headers (:Subject "extra-headers" :From "Notmuch Test Suite <test_suite@notmuchmail.org>" :To "Notmuch Test Suite <test_suite@notmuchmail.org>" :Date "Sat, 01 Jan 2000 12:00:00 +0000" :In-Reply-To "<parent@notmuch-test-suite>" :Received "from mail.example.com (mail.example.com [1.1.1.1])\011by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\011for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)")) ())))
|
|
|
|
EOF
|
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
|
2012-12-06 22:12:14 +01:00
|
|
|
test_done
|