]> git.notmuchmail.org Git - notmuch/blob - test/dump-restore
notmuch-dump: deprecate use of output file argument.
[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" "generate_message &&
8 notmuch new &&
9 notmuch dump > dump.expected"
10
11 test_begin_subtest "dump outfile"
12 notmuch dump dump-outfile.actual
13 test_expect_equal_file dump.expected dump-outfile.actual
14
15 test_begin_subtest "dump outfile # deprecated"
16 test_expect_equal "Warning: the output file argument of dump is deprecated."\
17   "$(notmuch dump /dev/null 2>&1)"
18
19 test_begin_subtest "dump outfile --"
20 notmuch dump dump-1-arg-dash.actual --
21 test_expect_equal_file dump.expected dump-1-arg-dash.actual
22
23 # Note, we assume all messages from cworth have a message-id
24 # containing cworth.org
25
26 grep cworth\.org dump.expected > dump-cworth.expected
27
28 test_begin_subtest "dump -- from:cworth"
29 notmuch dump -- from:cworth > dump-dash-cworth.actual
30 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
31
32 test_begin_subtest "dump outfile from:cworth"
33 notmuch dump dump-outfile-cworth.actual from:cworth
34 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
35
36 test_begin_subtest "dump outfile -- from:cworth"
37 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
38 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
39
40 test_begin_subtest "Clearing all tags"
41 sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected
42 notmuch restore < clear.expected
43 notmuch dump > clear.actual
44 test_expect_equal "$(< clear.actual)" "$(< clear.expected)"
45
46 test_begin_subtest "Restoring original tags"
47 notmuch restore < dump.expected
48 notmuch dump > dump.actual
49 test_expect_equal "$(< dump.actual)" "$(< dump.expected)"
50
51 test_expect_success "Restore with nothing to do" "notmuch restore dump.expected"
52
53 test_done