unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob f2349cc2f10eaba383982dbe4f1ee4946638fca2 4279 bytes (raw)
name: test/json 	 # 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
 
#!/bin/bash
test_description="--format=json output"
. ./test-lib.sh

EXPECTED=../json.expected-output

add_email_corpus

# Setup a duplicate message for testing
cp "$MAIL_DIR/cur/03:2," "$MAIL_DIR/cur/03:2-duplicate,"
increment_mtime "$MAIL_DIR/cur"
notmuch new >/dev/null

test_begin_subtest "Show single message: --format=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, \"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@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Cc\": \"\", \"Bcc\": \"\", \"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 single message: --format=json"
add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""
output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize)
test_expect_equal "$output" "[{\"thread\": \"XXX\",
\"timestamp\": 946728000,
\"matched\": 1,
\"total\": 1,
\"authors\": \"Notmuch Test Suite\",
\"subject\": \"json-search-subject\",
\"tags\": [\"inbox\", \"unread\"]}]"

test_begin_subtest "Show thread:"
output=$(notmuch show id:20091117190054.GU3165@dottiness.seas.harvard.edu)
expected=$(cat $EXPECTED/notmuch-show-thread-maildir-storage)
test_expect_equal "$output" "$expected"

test_begin_subtest "Show thread: --include-duplicates"
output=$(notmuch show --include-duplicates id:20091117190054.GU3165@dottiness.seas.harvard.edu)
expected=$(cat $EXPECTED/notmuch-show-thread-include-duplicates-maildir-storage)
test_expect_equal "$output" "$expected"

test_begin_subtest "Show thread: --format=json"
output=$(notmuch show --format=json id:20091117190054.GU3165@dottiness.seas.harvard.edu)
expected=$(cat $EXPECTED/notmuch-show-thread-format-json-maildir-storage)
test_expect_equal "$output" "$expected"

test_begin_subtest "Show thread: --format=json --include-duplicates"
output=$(notmuch show --format=json --include-duplicates id:20091117190054.GU3165@dottiness.seas.harvard.edu)
expected=$(cat $EXPECTED/notmuch-show-thread-format-json-include-duplicates-maildir-storage)
test_expect_equal "$output" "$expected"

test_begin_subtest "Search by subject (utf-8):"
add_message [subject]=utf8-sübjéct "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\""
output=$(notmuch search subject:utf8-sübjéct | notmuch_search_sanitize)
test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; utf8-sübjéct (inbox unread)"

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, \"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@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Cc\": \"\", \"Bcc\": \"\", \"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 "Search message: json, utf-8"
add_message "[subject]=\"json-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=json "jsön-search-méssage" | notmuch_search_sanitize)
test_expect_equal "$output" "[{\"thread\": \"XXX\",
\"timestamp\": 946728000,
\"matched\": 1,
\"total\": 1,
\"authors\": \"Notmuch Test Suite\",
\"subject\": \"json-search-utf8-body-sübjéct\",
\"tags\": [\"inbox\", \"unread\"]}]"

test_done

debug log:

solving f2349cc ...
found f2349cc in https://yhetil.org/notmuch/1295937564-2518-1-git-send-email-cworth@cworth.org/
found 7fe2a27 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 7fe2a27a8d6479bfd32c0d03b1c68b23ff7bf26f	test/json

applying [1/1] https://yhetil.org/notmuch/1295937564-2518-1-git-send-email-cworth@cworth.org/
diff --git a/test/json b/test/json
index 7fe2a27..f2349cc 100755

Checking patch test/json...
Applied patch test/json cleanly.

index at:
100755 f2349cc2f10eaba383982dbe4f1ee4946638fca2	test/json

(*) 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).