[RFC PATCH 07/14] Update tests that need to see filenames to use URIs
Ethan Glasser-Camp
ethan.glasser.camp at gmail.com
Mon Jun 25 13:51:50 PDT 2012
This fixes all tests except atomicity, which should be next.
Signed-off-by: Ethan Glasser-Camp <ethan at betacantrips.com>
---
test/emacs | 2 +-
test/json | 4 ++--
test/maildir-sync | 7 ++++---
test/multipart | 4 ++--
test/new | 6 +++---
test/search-folder-coherence | 2 +-
test/search-output | 4 ++--
test/test-lib.sh | 3 +++
8 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/test/emacs b/test/emacs
index e9f954c..c08791e 100755
--- a/test/emacs
+++ b/test/emacs
@@ -621,7 +621,7 @@ Stash my stashables
id:"bought"
bought
inbox,stashtest
-${gen_msg_filename}
+${gen_msg_uri}
http://mid.gmane.org/bought
http://marc.info/?i=bought
http://mail-archive.com/search?l=mid&q=bought
diff --git a/test/json b/test/json
index 6439788..be29fac 100755
--- a/test/json
+++ b/test/json
@@ -5,7 +5,7 @@ test_description="--format=json output"
test_begin_subtest "Show message: json"
add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""
output=$(notmuch show --format=json "json-show-message")
-test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
+test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_uri}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
test_begin_subtest "Search message: json"
add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""
@@ -22,7 +22,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",
test_begin_subtest "Show message: json, utf-8"
add_message "[subject]=\"json-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=json "jsön-show-méssage")
-test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]"
+test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_uri}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite at notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]"
test_begin_subtest "Show message: json, inline attachment filename"
subject='json-show-inline-attachment-filename'
diff --git a/test/maildir-sync b/test/maildir-sync
index 01348d3..a2e110e 100755
--- a/test/maildir-sync
+++ b/test/maildir-sync
@@ -8,7 +8,7 @@ test_description="maildir synchronization"
# --format=json" output includes some newlines. Also, need to avoid
# including the local value of MAIL_DIR in the result.
filter_show_json() {
- sed -e 's/, /,\n/g' | sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
+ sed -e 's/, /,\n/g' | sed -e "s|${MAIL_URI}/|MAIL_DIR/|"
echo
}
@@ -102,8 +102,9 @@ No new mail. Detected 1 file rename.
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Removing S flag (inbox unread)"
test_begin_subtest "Removing info from filename leaves tags unchanged"
-add_message [subject]='"Message to lose maildir info"' [filename]='message-to-lose-maildir-info' [dir]=cur
-notmuch tag -unread subject:"Message to lose maildir info"
+generate_message [subject]='"Message to lose maildir info"' [filename]='message-to-lose-maildir-info' [dir]=cur
+notmuch new > hrngh.new
+notmuch tag -unread subject:"Message to lose maildir info" > hrngh.tag
mv "$MAIL_DIR/cur/message-to-lose-maildir-info:2,S" "$MAIL_DIR/cur/message-without-maildir-info"
output=$(NOTMUCH_NEW)
output+="
diff --git a/test/multipart b/test/multipart
index 72d3927..ccf410b 100755
--- a/test/multipart
+++ b/test/multipart
@@ -109,7 +109,7 @@ notmuch new > /dev/null
test_begin_subtest "--format=text --part=0, full message"
notmuch show --format=text --part=0 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
cat <<EOF >EXPECTED
-message{ id:87liy5ap00.fsf at yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_DIR}/multipart
+message{ id:87liy5ap00.fsf at yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_URI}/multipart
header{
Carl Worth <cworth at cworth.org> (2001-01-05) (attachment inbox signed unread)
Subject: Multipart message
@@ -323,7 +323,7 @@ notmuch show --format=json --part=0 'id:87liy5ap00.fsf at yoom.home.cworth.org' | s
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED
-{"id": "87liy5ap00.fsf at 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 at cworth.org>", "To": "cworth at cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
+{"id": "87liy5ap00.fsf at yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_URI}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth at cworth.org>", "To": "cworth at 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 at cworth.org>", "To": "cworth at cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
diff --git a/test/new b/test/new
index cab7c01..e7852ec 100755
--- a/test/new
+++ b/test/new
@@ -171,9 +171,9 @@ touch "${MAIL_DIR}"/ignored_file
touch "${MAIL_DIR}"/.ignored_hidden_file
output=$(NOTMUCH_NEW 2>&1)
test_expect_equal "$output" \
-"Note: Ignoring non-mail file: ${MAIL_DIR}/.git/config
-Note: Ignoring non-mail file: ${MAIL_DIR}/.ignored_hidden_file
-Note: Ignoring non-mail file: ${MAIL_DIR}/ignored_file
+"Note: Ignoring non-mail file: ${MAIL_URI}/.git/config
+Note: Ignoring non-mail file: ${MAIL_URI}/.ignored_hidden_file
+Note: Ignoring non-mail file: ${MAIL_URI}/ignored_file
Added 1 new message to the database."
test_begin_subtest "Ignore files and directories specified in new.ignore"
diff --git a/test/search-folder-coherence b/test/search-folder-coherence
index 3f6ec76..08558db 100755
--- a/test/search-folder-coherence
+++ b/test/search-folder-coherence
@@ -27,7 +27,7 @@ cat <<EOF >EXPECTED
MAIL_DIR/msg-001
MAIL_DIR/spam/msg-001
EOF
-notmuch search --output=files id:$id_x | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
+notmuch search --output=files id:$id_x | sed -e "s,$MAIL_URI,MAIL_DIR," >OUTPUT
test_expect_equal_file OUTPUT EXPECTED
test_begin_subtest "Test matches folder:spam"
diff --git a/test/search-output b/test/search-output
index 8b57a43..d038dc7 100755
--- a/test/search-output
+++ b/test/search-output
@@ -181,7 +181,7 @@ EOF
test_expect_equal_file OUTPUT EXPECTED
test_begin_subtest "--output=files"
-notmuch search --output=files '*' | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
+notmuch search --output=files '*' | sed -e "s,$MAIL_URI,MAIL_DIR," >OUTPUT
cat <<EOF >EXPECTED
MAIL_DIR/cur/52:2,
MAIL_DIR/cur/53:2,
@@ -240,7 +240,7 @@ EOF
test_expect_equal_file OUTPUT EXPECTED
test_begin_subtest "--output=files --format=json"
-notmuch search --format=json --output=files '*' | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
+notmuch search --format=json --output=files '*' | sed -e "s,$MAIL_URI,MAIL_DIR," >OUTPUT
cat <<EOF >EXPECTED
["MAIL_DIR/cur/52:2,",
"MAIL_DIR/cur/53:2,",
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 06aaea2..195158c 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -287,6 +287,7 @@ generate_message ()
gen_msg_cnt=$((gen_msg_cnt + 1))
if [ -z "${template[filename]}" ]; then
+
gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)"
else
gen_msg_name=${template[filename]}
@@ -304,6 +305,7 @@ generate_message ()
gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
mkdir -p "$(dirname "$gen_msg_filename")"
fi
+ gen_msg_uri=maildir://$gen_msg_filename
if [ -z "${template[body]}" ]; then
template[body]="This is just a test message (#${gen_msg_cnt})"
@@ -1149,6 +1151,7 @@ export HOME="${TMP_DIRECTORY}/home"
mkdir -p "${HOME}"
MAIL_DIR="${TMP_DIRECTORY}/mail"
+MAIL_URI=maildir://$MAIL_DIR
export GNUPGHOME="${TMP_DIRECTORY}/gnupg"
export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
--
1.7.9.5
More information about the notmuch
mailing list