]> git.notmuchmail.org Git - notmuch/blob - test/T055-path-config.sh
lib: support splitting mail from database location.
[notmuch] / test / T055-path-config.sh
1 #!/usr/bin/env bash
2 test_description='Configuration of mail-root and database path'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 backup_config () {
6     local test_name=$(basename $0 .sh)
7     cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
8 }
9
10 restore_config () {
11     local test_name=$(basename $0 .sh)
12     export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
13     unset CONFIG_PATH
14     unset DATABASE_PATH
15     unset NOTMUCH_PROFILE
16     cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
17 }
18
19 split_config () {
20     local dir
21     backup_config
22     dir="$TMP_DIRECTORY/database.$test_count"
23     rm -rf $dir
24     mkdir $dir
25     notmuch config set database.path $dir
26     notmuch config set database.mail_root $MAIL_DIR
27     DATABASE_PATH=$dir
28 }
29
30
31
32 for config in traditional split; do
33     # start each set of tests with a known set of messages
34     add_email_corpus
35
36     case $config in
37         traditional)
38             backup_config
39             ;;
40         split)
41             split_config
42             mv mail/.notmuch/xapian $DATABASE_PATH
43             ;;
44     esac
45
46     test_begin_subtest "count ($config)"
47     output=$(notmuch count '*')
48     test_expect_equal "$output" '52'
49
50     test_begin_subtest "count+tag ($config)"
51     tag="tag${RANDOM}"
52     notmuch tag +$tag '*'
53     output=$(notmuch count tag:$tag)
54     notmuch tag -$tag '*'
55     test_expect_equal "$output" '52'
56
57     test_begin_subtest "address ($config)"
58     notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
59     cat <<EOF >EXPECTED
60 Carl Worth <cworth@cworth.org>
61 notmuch@notmuchmail.org
62 EOF
63     test_expect_equal_file EXPECTED OUTPUT
64
65     test_begin_subtest "dump ($config)"
66     notmuch dump is:attachment and is:signed | sort > OUTPUT
67     cat <<EOF > EXPECTED
68 #notmuch-dump batch-tag:3 config,properties,tags
69 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
70 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
71 EOF
72     test_expect_equal_file EXPECTED OUTPUT
73
74     test_begin_subtest "dump + tag + restore ($config)"
75     notmuch dump '*' > EXPECTED
76     notmuch tag -inbox '*'
77     notmuch restore < EXPECTED
78     notmuch dump > OUTPUT
79     test_expect_equal_file EXPECTED OUTPUT
80
81     test_begin_subtest "reindex ($config)"
82     notmuch search --output=messages '*' > EXPECTED
83     notmuch reindex '*'
84     notmuch search --output=messages '*' > OUTPUT
85     test_expect_equal_file EXPECTED OUTPUT
86
87     restore_config
88 done
89
90 test_done