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 &&
|
|
|
|
notmuch restore clear.expected &&
|
|
|
|
notmuch dump > clear.actual &&
|
|
|
|
test_cmp clear.expected clear.actual'
|
|
|
|
|
2011-10-21 18:04:46 +02:00
|
|
|
test_subtest_known_broken # missing --accumuluate
|
|
|
|
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' \
|
|
|
|
'notmuch restore dump.expected &&
|
|
|
|
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'
|
|
|
|
|
2011-10-21 18:04:46 +02:00
|
|
|
test_subtest_known_broken # missing --accumuluate
|
|
|
|
test_expect_success 'Restore with nothing to do, II' \
|
|
|
|
'notmuch restore --accumulate dump.expected &&
|
|
|
|
notmuch dump > dump.actual &&
|
|
|
|
test_cmp dump.expected dump.actual'
|
|
|
|
|
|
|
|
test_subtest_known_broken # missing --accumuluate
|
|
|
|
test_expect_success 'Restore with nothing to do, III' \
|
|
|
|
'notmuch restore --accumulate < clear.expected &&
|
|
|
|
notmuch dump > dump.actual &&
|
|
|
|
test_cmp dump.expected dump.actual'
|
|
|
|
|
2011-10-19 23:03:12 +02:00
|
|
|
# notmuch restore currently only considers the first argument.
|
|
|
|
test_subtest_known_broken
|
|
|
|
test_expect_success 'Invalid restore invocation' \
|
|
|
|
'test_must_fail notmuch restore dump.expected another_one'
|
2010-09-18 00:25:39 +02:00
|
|
|
|
2011-10-10 14:27:20 +02:00
|
|
|
test_begin_subtest "dump outfile"
|
|
|
|
notmuch dump dump-outfile.actual
|
|
|
|
test_expect_equal_file dump.expected dump-outfile.actual
|
|
|
|
|
2011-10-10 15:44:07 +02:00
|
|
|
test_begin_subtest "dump outfile # deprecated"
|
|
|
|
test_expect_equal "Warning: the output file argument of dump is deprecated."\
|
|
|
|
"$(notmuch dump /dev/null 2>&1)"
|
|
|
|
|
2011-10-10 14:27:20 +02:00
|
|
|
test_begin_subtest "dump outfile --"
|
|
|
|
notmuch dump dump-1-arg-dash.actual --
|
|
|
|
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
|
|
|
|
|
|
|
|
test_begin_subtest "dump outfile from:cworth"
|
|
|
|
notmuch dump dump-outfile-cworth.actual from:cworth
|
|
|
|
test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
|
|
|
|
|
|
|
|
test_begin_subtest "dump outfile -- from:cworth"
|
|
|
|
notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
|
|
|
|
test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
|
|
|
|
|
2010-06-10 08:48:03 +02:00
|
|
|
test_done
|