]> git.notmuchmail.org Git - notmuch/blob - test/dump-restore
0f62d9da2e8b0ad6ffc1c7e333e4eeef0883007f
[notmuch] / test / dump-restore
1 #!/usr/bin/env bash
2 test_description="\"notmuch dump\" and \"notmuch restore\""
3 . ./test-lib.sh
4
5 add_email_corpus
6
7 test_expect_success 'Dumping all tags' \
8   'generate_message &&
9   notmuch new &&
10   notmuch dump > dump.expected'
11
12 # The use of from:cworth is rather arbitrary: it matches some of the
13 # email corpus' messages, but not all of them.
14
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'
19
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'
25
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'
32
33 test_expect_success 'Restoring original tags' \
34   'notmuch restore dump.expected &&
35   notmuch dump > dump.actual &&
36   test_cmp dump.expected dump.actual'
37
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'
42
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'
48
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'
54
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'
59
60 test_begin_subtest "dump outfile"
61 notmuch dump dump-outfile.actual
62 test_expect_equal_file dump.expected dump-outfile.actual
63
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)"
67
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
71
72 # Note, we assume all messages from cworth have a message-id
73 # containing cworth.org
74
75 grep 'cworth[.]org' dump.expected > dump-cworth.expected
76
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
80
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
84
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
88
89 test_done