2 test_description="\"notmuch dump\" and \"notmuch restore\""
7 test_expect_success 'Dumping all tags' \
10 notmuch dump > dump.expected'
12 # The use of from:cworth is rather arbitrary: it matches some of the
13 # email corpus' messages, but not all of them.
15 test_expect_success 'Dumping all tags II' \
16 'notmuch tag +ABC +DEF -- from:cworth &&
17 notmuch dump > dump-ABC_DEF.expected &&
18 ! cmp dump.expected dump-ABC_DEF.expected'
20 test_expect_success 'Clearing all tags' \
21 'sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected &&
22 notmuch restore clear.expected &&
23 notmuch dump > clear.actual &&
24 test_cmp clear.expected clear.actual'
26 test_subtest_known_broken # missing --accumuluate
27 test_expect_success 'Accumulate original tags' \
28 'notmuch tag +ABC +DEF -- from:cworth &&
29 notmuch restore --accumulate < dump.expected &&
30 notmuch dump > dump.actual &&
31 test_cmp dump-ABC_DEF.expected dump.actual'
33 test_expect_success 'Restoring original tags' \
34 'notmuch restore dump.expected &&
35 notmuch dump > dump.actual &&
36 test_cmp dump.expected dump.actual'
38 test_expect_success 'Restore with nothing to do' \
39 'notmuch restore < dump.expected &&
40 notmuch dump > dump.actual &&
41 test_cmp dump.expected dump.actual'
43 test_subtest_known_broken # missing --accumuluate
44 test_expect_success 'Restore with nothing to do, II' \
45 'notmuch restore --accumulate dump.expected &&
46 notmuch dump > dump.actual &&
47 test_cmp dump.expected dump.actual'
49 test_subtest_known_broken # missing --accumuluate
50 test_expect_success 'Restore with nothing to do, III' \
51 'notmuch restore --accumulate < clear.expected &&
52 notmuch dump > dump.actual &&
53 test_cmp dump.expected dump.actual'
55 # notmuch restore currently only considers the first argument.
56 test_subtest_known_broken
57 test_expect_success 'Invalid restore invocation' \
58 'test_must_fail notmuch restore dump.expected another_one'
60 test_begin_subtest "dump outfile"
61 notmuch dump dump-outfile.actual
62 test_expect_equal_file dump.expected dump-outfile.actual
64 test_begin_subtest "dump outfile # deprecated"
65 test_expect_equal "Warning: the output file argument of dump is deprecated."\
66 "$(notmuch dump /dev/null 2>&1)"
68 test_begin_subtest "dump outfile --"
69 notmuch dump dump-1-arg-dash.actual --
70 test_expect_equal_file dump.expected dump-1-arg-dash.actual
72 # Note, we assume all messages from cworth have a message-id
73 # containing cworth.org
75 grep 'cworth[.]org' dump.expected > dump-cworth.expected
77 test_begin_subtest "dump -- from:cworth"
78 notmuch dump -- from:cworth > dump-dash-cworth.actual
79 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
81 test_begin_subtest "dump outfile from:cworth"
82 notmuch dump dump-outfile-cworth.actual from:cworth
83 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
85 test_begin_subtest "dump outfile -- from:cworth"
86 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
87 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual