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 --input=clear.expected &&
23 notmuch dump > clear.actual &&
24 test_cmp clear.expected clear.actual'
26 test_expect_success 'Accumulate original tags' \
27 'notmuch tag +ABC +DEF -- from:cworth &&
28 notmuch restore --accumulate < dump.expected &&
29 notmuch dump > dump.actual &&
30 test_cmp dump-ABC_DEF.expected dump.actual'
32 test_expect_success 'Restoring original tags' \
33 'notmuch restore --input=dump.expected &&
34 notmuch dump > dump.actual &&
35 test_cmp dump.expected dump.actual'
37 test_expect_success 'Restore with nothing to do' \
38 'notmuch restore < dump.expected &&
39 notmuch dump > dump.actual &&
40 test_cmp dump.expected dump.actual'
42 test_expect_success 'Restore with nothing to do, II' \
43 'notmuch restore --accumulate --input=dump.expected &&
44 notmuch dump > dump.actual &&
45 test_cmp dump.expected dump.actual'
47 test_expect_success 'Restore with nothing to do, III' \
48 'notmuch restore --accumulate < clear.expected &&
49 notmuch dump > dump.actual &&
50 test_cmp dump.expected dump.actual'
52 # notmuch restore currently only considers the first argument.
53 test_expect_success 'Invalid restore invocation' \
54 'test_must_fail notmuch restore --input=dump.expected another_one'
56 test_begin_subtest "dump --output=outfile"
57 notmuch dump --output=dump-outfile.actual
58 test_expect_equal_file dump.expected dump-outfile.actual
60 test_begin_subtest "dump --output=outfile --"
61 notmuch dump --output=dump-1-arg-dash.actual --
62 test_expect_equal_file dump.expected dump-1-arg-dash.actual
64 # Note, we assume all messages from cworth have a message-id
65 # containing cworth.org
67 grep 'cworth[.]org' dump.expected > dump-cworth.expected
69 test_begin_subtest "dump -- from:cworth"
70 notmuch dump -- from:cworth > dump-dash-cworth.actual
71 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
73 test_begin_subtest "dump --output=outfile from:cworth"
74 notmuch dump --output=dump-outfile-cworth.actual from:cworth
75 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
77 test_begin_subtest "dump --output=outfile -- from:cworth"
78 notmuch dump --output=dump-outfile-dash-inbox.actual -- from:cworth
79 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual