2010-12-01 21:27:52 +01:00
|
|
|
#!/usr/bin/env bash
|
2010-06-10 08:48:03 +02:00
|
|
|
test_description="\"notmuch dump\" and \"notmuch restore\""
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2010-09-21 01:40:35 +02:00
|
|
|
add_email_corpus
|
|
|
|
|
2011-10-19 23:03:12 +02:00
|
|
|
test_expect_success 'Dumping all tags' \
|
|
|
|
'generate_message &&
|
|
|
|
notmuch new &&
|
|
|
|
notmuch dump > dump.expected'
|
|
|
|
|
2011-10-21 18:04:46 +02:00
|
|
|
# The use of from:cworth is rather arbitrary: it matches some of the
|
|
|
|
# email corpus' messages, but not all of them.
|
|
|
|
|
|
|
|
test_expect_success 'Dumping all tags II' \
|
|
|
|
'notmuch tag +ABC +DEF -- from:cworth &&
|
|
|
|
notmuch dump > dump-ABC_DEF.expected &&
|
|
|
|
! cmp dump.expected dump-ABC_DEF.expected'
|
|
|
|
|
2011-10-19 23:03:12 +02:00
|
|
|
test_expect_success 'Clearing all tags' \
|
|
|
|
'sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected &&
|
2012-08-04 14:55:45 +02:00
|
|
|
notmuch restore --input=clear.expected &&
|
2011-10-19 23:03:12 +02:00
|
|
|
notmuch dump > clear.actual &&
|
|
|
|
test_cmp clear.expected clear.actual'
|
|
|
|
|
2011-10-21 18:04:46 +02:00
|
|
|
test_expect_success 'Accumulate original tags' \
|
|
|
|
'notmuch tag +ABC +DEF -- from:cworth &&
|
|
|
|
notmuch restore --accumulate < dump.expected &&
|
|
|
|
notmuch dump > dump.actual &&
|
|
|
|
test_cmp dump-ABC_DEF.expected dump.actual'
|
|
|
|
|
2011-10-19 23:03:12 +02:00
|
|
|
test_expect_success 'Restoring original tags' \
|
2012-08-04 14:55:45 +02:00
|
|
|
'notmuch restore --input=dump.expected &&
|
2011-10-19 23:03:12 +02:00
|
|
|
notmuch dump > dump.actual &&
|
|
|
|
test_cmp dump.expected dump.actual'
|
|
|
|
|
|
|
|
test_expect_success 'Restore with nothing to do' \
|
|
|
|
'notmuch restore < dump.expected &&
|
|
|
|
notmuch dump > dump.actual &&
|
|
|
|
test_cmp dump.expected dump.actual'
|
|
|
|
|
2012-11-17 15:18:00 +01:00
|
|
|
test_expect_success 'Accumulate with existing tags' \
|
2012-08-04 14:55:45 +02:00
|
|
|
'notmuch restore --accumulate --input=dump.expected &&
|
2011-10-21 18:04:46 +02:00
|
|
|
notmuch dump > dump.actual &&
|
|
|
|
test_cmp dump.expected dump.actual'
|
|
|
|
|
2012-11-17 15:18:00 +01:00
|
|
|
test_expect_success 'Accumulate with no tags' \
|
2011-10-21 18:04:46 +02:00
|
|
|
'notmuch restore --accumulate < clear.expected &&
|
|
|
|
notmuch dump > dump.actual &&
|
|
|
|
test_cmp dump.expected dump.actual'
|
|
|
|
|
2012-11-16 13:31:19 +01:00
|
|
|
test_expect_success 'Accumulate with new tags' \
|
|
|
|
'notmuch restore --input=dump.expected &&
|
|
|
|
notmuch restore --accumulate --input=dump-ABC_DEF.expected &&
|
|
|
|
notmuch dump > OUTPUT.$test_count &&
|
|
|
|
notmuch restore --input=dump.expected &&
|
|
|
|
test_cmp dump-ABC_DEF.expected OUTPUT.$test_count'
|
|
|
|
|
2011-10-19 23:03:12 +02:00
|
|
|
# notmuch restore currently only considers the first argument.
|
|
|
|
test_expect_success 'Invalid restore invocation' \
|
2012-08-04 14:55:45 +02:00
|
|
|
'test_must_fail notmuch restore --input=dump.expected another_one'
|
2010-09-18 00:25:39 +02:00
|
|
|
|
2012-08-04 04:23:11 +02:00
|
|
|
test_begin_subtest "dump --output=outfile"
|
|
|
|
notmuch dump --output=dump-outfile.actual
|
2011-10-10 14:27:20 +02:00
|
|
|
test_expect_equal_file dump.expected dump-outfile.actual
|
|
|
|
|
2012-08-04 04:23:11 +02:00
|
|
|
test_begin_subtest "dump --output=outfile --"
|
|
|
|
notmuch dump --output=dump-1-arg-dash.actual --
|
2011-10-10 14:27:20 +02:00
|
|
|
test_expect_equal_file dump.expected dump-1-arg-dash.actual
|
|
|
|
|
|
|
|
# Note, we assume all messages from cworth have a message-id
|
|
|
|
# containing cworth.org
|
|
|
|
|
2011-10-21 02:14:30 +02:00
|
|
|
grep 'cworth[.]org' dump.expected > dump-cworth.expected
|
2011-10-10 14:27:20 +02:00
|
|
|
|
|
|
|
test_begin_subtest "dump -- from:cworth"
|
|
|
|
notmuch dump -- from:cworth > dump-dash-cworth.actual
|
|
|
|
test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
|
|
|
|
|
2012-08-04 04:23:11 +02:00
|
|
|
test_begin_subtest "dump --output=outfile from:cworth"
|
|
|
|
notmuch dump --output=dump-outfile-cworth.actual from:cworth
|
2011-10-10 14:27:20 +02:00
|
|
|
test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
|
|
|
|
|
2012-08-04 04:23:11 +02:00
|
|
|
test_begin_subtest "dump --output=outfile -- from:cworth"
|
|
|
|
notmuch dump --output=dump-outfile-dash-inbox.actual -- from:cworth
|
2011-10-10 14:27:20 +02:00
|
|
|
test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
|
|
|
|
|
2012-08-05 20:13:13 +02:00
|
|
|
test_begin_subtest 'roundtripping random message-ids and tags'
|
|
|
|
test_subtest_known_broken
|
|
|
|
${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} \
|
|
|
|
--num-messages=10
|
|
|
|
|
|
|
|
notmuch dump| \
|
|
|
|
${TEST_DIRECTORY}/hex-xcode --direction=encode| \
|
|
|
|
sort > EXPECTED.$test_count
|
|
|
|
|
|
|
|
notmuch tag +this_tag_is_very_unlikely_to_be_random '*'
|
|
|
|
|
|
|
|
${TEST_DIRECTORY}/hex-xcode --direction=decode < EXPECTED.$test_count | \
|
|
|
|
notmuch restore 2>/dev/null
|
|
|
|
|
|
|
|
notmuch dump| \
|
|
|
|
${TEST_DIRECTORY}/hex-xcode --direction=encode| \
|
|
|
|
sort > OUTPUT.$test_count
|
|
|
|
|
|
|
|
test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
|
|
|
|
|
2010-06-10 08:48:03 +02:00
|
|
|
test_done
|