]> git.notmuchmail.org Git - notmuch/blob - test/dump-restore
test: add tests for command line arguments to notmuch-dump
[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 test_subtest_known_broken
26 notmuch dump -- from:cworth > dump-dash-cworth.actual
27 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
28
29 test_begin_subtest "dump outfile from:cworth"
30 test_subtest_known_broken
31 notmuch dump dump-outfile-cworth.actual from:cworth
32 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
33
34 test_begin_subtest "dump outfile -- from:cworth"
35 test_subtest_known_broken
36 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
37 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
38
39 test_begin_subtest "Clearing all tags"
40 sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected
41 notmuch restore < clear.expected
42 notmuch dump > clear.actual
43 test_expect_equal "$(< clear.actual)" "$(< clear.expected)"
44
45 test_begin_subtest "Restoring original tags"
46 notmuch restore < dump.expected
47 notmuch dump > dump.actual
48 test_expect_equal "$(< dump.actual)" "$(< dump.expected)"
49
50 test_expect_success "Restore with nothing to do" "notmuch restore dump.expected"
51
52 test_done