]> git.notmuchmail.org Git - notmuch/blob - test/dump-restore
test/dump-restore: expand test suite for dump-restore, make more robust
[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 test_expect_success 'Clearing all tags' \
13   'sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected &&
14   notmuch restore clear.expected &&
15   notmuch dump > clear.actual &&
16   test_cmp clear.expected clear.actual'
17
18 test_expect_success 'Restoring original tags' \
19   'notmuch restore dump.expected &&
20   notmuch dump > dump.actual &&
21   test_cmp dump.expected dump.actual'
22
23 test_expect_success 'Restore with nothing to do' \
24   'notmuch restore < dump.expected &&
25   notmuch dump > dump.actual &&
26   test_cmp dump.expected dump.actual'
27
28 # notmuch restore currently only considers the first argument.
29 test_subtest_known_broken
30 test_expect_success 'Invalid restore invocation' \
31   'test_must_fail notmuch restore dump.expected another_one'
32
33 test_begin_subtest "dump outfile"
34 notmuch dump dump-outfile.actual
35 test_expect_equal_file dump.expected dump-outfile.actual
36
37 test_begin_subtest "dump outfile # deprecated"
38 test_expect_equal "Warning: the output file argument of dump is deprecated."\
39   "$(notmuch dump /dev/null 2>&1)"
40
41 test_begin_subtest "dump outfile --"
42 notmuch dump dump-1-arg-dash.actual --
43 test_expect_equal_file dump.expected dump-1-arg-dash.actual
44
45 # Note, we assume all messages from cworth have a message-id
46 # containing cworth.org
47
48 grep cworth\.org dump.expected > dump-cworth.expected
49
50 test_begin_subtest "dump -- from:cworth"
51 notmuch dump -- from:cworth > dump-dash-cworth.actual
52 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
53
54 test_begin_subtest "dump outfile from:cworth"
55 notmuch dump dump-outfile-cworth.actual from:cworth
56 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
57
58 test_begin_subtest "dump outfile -- from:cworth"
59 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
60 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
61
62 test_done