aboutsummaryrefslogtreecommitdiff
path: root/test/T520-show.sh
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2022-07-01 18:45:44 -0300
committerDavid Bremner <david@tethera.net>2022-07-30 08:41:50 -0300
commit4612f3eb3dbf16bf98ccbadef77d7a6f6361e692 (patch)
tree11f6350c5731fe3777d66cbb87e198377c0c342e /test/T520-show.sh
parentcef5eaaef61b1f4dde6276ef267fb923f1b16680 (diff)
CLI/show: support --duplicate for structured output
This introduces a new mandatory key for message structures, namely "duplicate". Per convention in devel/schemata this does _not_ increase the format version. This means that clients are responsible for checking that it exists, and not crashing if it does not. The main functional change is teaching mime_node_open to understand a 'duplicate' argument. Support for --duplicate in notmuch-reply would make sense, but we defer it to a later commit.
Diffstat (limited to 'test/T520-show.sh')
-rwxr-xr-xtest/T520-show.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/T520-show.sh b/test/T520-show.sh
index 12bde6c7..c7b73a6d 100755
--- a/test/T520-show.sh
+++ b/test/T520-show.sh
@@ -45,4 +45,40 @@ if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
fi
+add_email_corpus duplicate
+
+ID1=debian/2.6.1.dfsg-4-1-g87ea161@87ea161e851dfb1ea324af00e4ecfccc18875e15
+
+test_begin_subtest "format json, --duplicate=2, duplicate key"
+output=$(notmuch show --format=json --duplicate=2 id:${ID1})
+test_json_nodes <<<"$output" "dup:['duplicate']=2"
+
+test_begin_subtest "format json, subject, --duplicate=1"
+output=$(notmuch show --format=json --duplicate=1 id:${ID1})
+file=$(notmuch search --output=files id:${ID1} | head -n 1)
+subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
+test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""
+
+test_begin_subtest "format json, subject, --duplicate=2"
+output=$(notmuch show --format=json --duplicate=2 id:${ID1})
+file=$(notmuch search --output=files id:${ID1} | tail -n 1)
+subject=$(sed -n 's/^Subject: \(.*\)$/\1/p' < $file)
+test_json_nodes <<<"$output" "subject:['headers']['Subject']=\"$subject\""
+
+ID2=87r2geywh9.fsf@tethera.net
+for dup in {1..2}; do
+ test_begin_subtest "format json, body, --duplicate=${dup}"
+ output=$(notmuch show --format=json --duplicate=${dup} id:${ID2} | \
+ $NOTMUCH_PYTHON -B "$NOTMUCH_SRCDIR"/test/json_check_nodes.py "body:['body'][0]['content']" | \
+ grep '^# body')
+ test_expect_equal "$output" "# body ${dup}"
+done
+
+ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
+for dup in {1..5}; do
+ test_begin_subtest "format json, --duplicate=${dup}, 'duplicate' key"
+ output=$(notmuch show --format=json --duplicate=${dup} id:${ID3})
+ test_json_nodes <<<"$output" "dup:['duplicate']=${dup}"
+done
+
test_done