#!/bin/bash test_description="maildir synchronization" . ./test-lib.sh # Much easier to examine differences if the "notmuch show # --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/|" echo } cat >> "$NOTMUCH_CONFIG" < /dev/null output=$(notmuch search tag:inbox | notmuch_search_sanitize) output+=" " mv "${gen_msg_filename}" "${gen_msg_filename}S" increment_mtime "$(dirname "${gen_msg_filename}")" output+=$(NOTMUCH_NEW) output+=" " output+=$(notmuch search tag:inbox | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread) No new mail. Detected 1 file rename. thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)" test_begin_subtest "Adding message with 'S' flag prevents 'unread' tag" add_message [subject]='"test message 2"' [date]='"Sat, 01 Jan 2000 12:00:00 -0000"' [filename]='"msg-002:2,S"' && output=$(notmuch search tag:inbox | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox) thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox)" test_begin_subtest "Adding 'replied' flag adds 'R' tag to filename" notmuch tag +replied tag:inbox output=$(ls -1 "${MAIL_DIR}") test_expect_equal "$output" "msg-001:2,RS msg-002:2,RS" test_begin_subtest "notmuch show works with renamed file (without notmuch new)" output=$(notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show_json) test_expect_equal "$output" '[[[{"id": "msg-001@notmuch-test-suite", "match": true, "filename": "MAIL_DIR/msg-001:2,RS", "timestamp": 946728000, "date_relative": "2000-01-01", "tags": ["inbox","replied"], "headers": {"Subject": "test message", "From": "Notmuch Test Suite ", "To": "Notmuch Test Suite ", "Cc": "", "Bcc": "", "Date": "Sat, 01 Jan 2000 12:00:00 -0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "This is just a test message (#1)\n"}]}, []]]]' test_expect_success 'notmuch reply works with renamed file (without notmuch new)' 'notmuch reply id:msg-001@notmuch-test-suite' test_begin_subtest "notmuch new detects no file rename after tag->flag synchronization" increment_mtime "$(dirname ${gen_msg_filename})" output=$(NOTMUCH_NEW) test_expect_equal "$output" "No new mail." test_expect_success "Add a message to new/ without info" ' generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new && NOTMUCH_NEW > actual && test_cmp - actual < actual && test_cmp - actual < expected && notmuch show id:$gen_msg_id|grep -o "filename:.*$" > actual && test_cmp expected actual && test -f "$gen_msg_filename" ' test_expect_success "Check that the message was not renamed" ' ls "${MAIL_DIR}/new" > actual && test_cmp - actual < actual && test_cmp - actual < actual && test_cmp - actual < actual && test_cmp - actual < actual test_cmp - actual < actual && test_cmp - actual < actual && test_cmp - actual < actual && test_cmp - actual < actual && test_cmp - actual < expected && mv $MAIL_DIR/msg-001:2,RS $MAIL_DIR/msg-001:2, && mv $MAIL_DIR/msg-002:2,RS $MAIL_DIR/msg-002:2, && increment_mtime $MAIL_DIR ' test_expect_success 'Test whether dump/new/restore synchronizes the maildir flags with the database' ' notmuch dump dump.txt && notmuch new && notmuch restore dump.txt && ls $MAIL_DIR > actual && test_cmp expected actual ' test_done