]> git.notmuchmail.org Git - notmuch/blob - test/T030-config.sh
emacs: show: improve handling of mark read tagging errors
[notmuch] / test / T030-config.sh
1 #!/usr/bin/env bash
2
3 test_description='"notmuch config"'
4 . ./test-lib.sh || exit 1
5
6 test_begin_subtest "Get string value"
7 test_expect_equal "$(notmuch config get user.name)" "Notmuch Test Suite"
8
9 test_begin_subtest "Get list value"
10 test_expect_equal "$(notmuch config get new.tags)" "\
11 unread
12 inbox"
13
14 test_begin_subtest "Set string value"
15 notmuch config set foo.string "this is a string value"
16 test_expect_equal "$(notmuch config get foo.string)" "this is a string value"
17
18 test_begin_subtest "Set string value again"
19 notmuch config set foo.string "this is another string value"
20 test_expect_equal "$(notmuch config get foo.string)" "this is another string value"
21
22 test_begin_subtest "Set list value"
23 notmuch config set foo.list this "is a" "list value"
24 test_expect_equal "$(notmuch config get foo.list)" "\
25 this
26 is a
27 list value"
28
29 test_begin_subtest "Set list value again"
30 notmuch config set foo.list this "is another" "list value"
31 test_expect_equal "$(notmuch config get foo.list)" "\
32 this
33 is another
34 list value"
35
36 test_begin_subtest "Remove key"
37 notmuch config set foo.remove baz
38 notmuch config set foo.remove
39 test_expect_equal "$(notmuch config get foo.remove)" ""
40
41 test_begin_subtest "Remove non-existent key"
42 notmuch config set foo.nonexistent
43 test_expect_equal "$(notmuch config get foo.nonexistent)" ""
44
45 test_begin_subtest "List all items"
46 notmuch config list 2>&1 | notmuch_config_sanitize > OUTPUT
47 cat <<EOF > EXPECTED
48 Error opening database at MAIL_DIR/.notmuch: No such file or directory
49 database.path=MAIL_DIR
50 user.name=Notmuch Test Suite
51 user.primary_email=test_suite@notmuchmail.org
52 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
53 new.tags=unread;inbox;
54 new.ignore=
55 search.exclude_tags=
56 maildir.synchronize_flags=true
57 crypto.gpg_path=gpg
58 foo.string=this is another string value
59 foo.list=this;is another;list value;
60 built_with.compact=something
61 built_with.field_processor=something
62 EOF
63 test_expect_equal_file EXPECTED OUTPUT
64
65 test_begin_subtest "Top level --config=FILE option"
66 cp "${NOTMUCH_CONFIG}" alt-config
67 notmuch --config=alt-config config set user.name "Another Name"
68 test_expect_equal "$(notmuch --config=alt-config config get user.name)" \
69     "Another Name"
70
71 test_begin_subtest "Top level --config=FILE option changed the right file"
72 test_expect_equal "$(notmuch config get user.name)" \
73     "Notmuch Test Suite"
74
75 test_begin_subtest "Read config file through a symlink"
76 ln -s alt-config alt-config-link
77 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
78     "Another Name"
79
80 test_begin_subtest "Write config file through a symlink"
81 notmuch --config=alt-config-link config set user.name "Link Name"
82 test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \
83     "Link Name"
84
85 test_begin_subtest "Writing config file through symlink follows symlink"
86 test_expect_equal "$(readlink alt-config-link)" "alt-config"
87
88 test_done