]> git.notmuchmail.org Git - notmuch/blob - test/dump-restore
e7edd9b2573df7fc43e8a2565513c341202e4579
[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 --"
16 notmuch dump dump-1-arg-dash.actual --
17 test_expect_equal_file dump.expected dump-1-arg-dash.actual
18
19 # Note, we assume all messages from cworth have a message-id
20 # containing cworth.org
21
22 grep cworth\.org dump.expected > dump-cworth.expected
23
24 test_begin_subtest "dump -- from:cworth"
25 notmuch dump -- from:cworth > dump-dash-cworth.actual
26 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
27
28 test_begin_subtest "dump outfile from:cworth"
29 notmuch dump dump-outfile-cworth.actual from:cworth
30 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
31
32 test_begin_subtest "dump outfile -- from:cworth"
33 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
34 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
35
36 test_begin_subtest "Clearing all tags"
37 sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected
38 notmuch restore < clear.expected
39 notmuch dump > clear.actual
40 test_expect_equal "$(< clear.actual)" "$(< clear.expected)"
41
42 test_begin_subtest "Restoring original tags"
43 notmuch restore < dump.expected
44 notmuch dump > dump.actual
45 test_expect_equal "$(< dump.actual)" "$(< dump.expected)"
46
47 test_expect_success "Restore with nothing to do" "notmuch restore dump.expected"
48
49 test_done