]> git.notmuchmail.org Git - notmuch/blob - test/T210-raw.sh
test: sort the output of the "prefix" test in T610-message-property
[notmuch] / test / T210-raw.sh
1 #!/usr/bin/env bash
2
3 test_description='notmuch show --format=raw'
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6 add_message
7 add_message
8
9 test_begin_subtest "Attempt to show multiple raw messages"
10 output=$(notmuch show --format=raw "*" 2>&1)
11 test_expect_equal "$output" "Error: search term did not match precisely one message (matched 2 messages)."
12
13 test_begin_subtest "Show a raw message"
14 output=$(notmuch show --format=raw id:msg-001@notmuch-test-suite | notmuch_date_sanitize)
15 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
16 To: Notmuch Test Suite <test_suite@notmuchmail.org>
17 Message-Id: <msg-001@notmuch-test-suite>
18 Subject: Test message #1
19 Date: GENERATED_DATE
20
21 This is just a test message (#1)"
22
23 test_begin_subtest "Show another raw message"
24 output=$(notmuch show --format=raw id:msg-002@notmuch-test-suite | notmuch_date_sanitize)
25 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
26 To: Notmuch Test Suite <test_suite@notmuchmail.org>
27 Message-Id: <msg-002@notmuch-test-suite>
28 Subject: Test message #2
29 Date: GENERATED_DATE
30
31 This is just a test message (#2)"
32
33 test_python <<EOF
34 from email.message import EmailMessage
35 for pow in range(10,21):
36     size = 2 ** pow
37     msg = EmailMessage()
38     msg['Subject'] = 'message with {:07d} bytes'.format(size)
39     msg['From'] = 'Notmuch Test Suite <test_suite@notmuchmail.org>'
40     msg['To'] = msg['From']
41     msg['Message-Id'] = 'size-{:07d}@notmuch-test-suite'.format(size)
42     content = ""
43     msg.set_content("")
44     padding = size - len(bytes(msg))
45     lines = []
46     while padding > 0:
47         line = '.' * min(padding, 72)
48         lines.append(line)
49         padding = padding - len(line) - 1
50     content ='\n'.join(lines)
51     msg.set_content(content)
52     with open('mail/size-{:07d}'.format(size), 'wb') as f:
53         f.write(bytes(msg))
54 EOF
55
56 notmuch new --quiet
57
58 for pow in {10..20}; do
59     printf -v size "%07d" $((2**$pow))
60     test_begin_subtest "content, message of size $size"
61     notmuch show --format=raw subject:$size > OUTPUT
62     test_expect_equal_file mail/size-$size OUTPUT
63     test_begin_subtest "return value, message of size $size"
64     test_expect_success  "notmuch show --format=raw subject:$size > /dev/null"
65 done
66
67 test_done