2 test_description="library config API"
4 . $(dirname "$0")/test-lib.sh || exit 1
8 _libconfig_sanitize() {
9 ${NOTMUCH_PYTHON} /dev/fd/3 3<<'EOF'
10 import os, sys, pwd, socket
12 pw = pwd.getpwuid(os.getuid())
14 name = pw.pw_gecos.partition(",")[0]
15 fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
16 socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
19 l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1)
20 l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1)
22 l = l.replace("'" + name, "'USER_FULL_NAME", 1)
30 #include <notmuch-test.h>
32 int main (int argc, char** argv)
34 notmuch_database_t *db;
36 notmuch_status_t stat;
39 for (int i = 1; i < argc; i++)
40 if (strcmp (argv[i], "%NULL%") == 0) argv[i] = NULL;
42 stat = notmuch_database_open_with_config (argv[1],
43 NOTMUCH_DATABASE_MODE_READ_WRITE,
48 if (stat != NOTMUCH_STATUS_SUCCESS) {
49 fprintf (stderr, "error opening database\n%s\n%s\n", notmuch_status_to_string (stat), msg ? msg : "");
55 EXPECT0(notmuch_database_destroy(db));
59 test_begin_subtest "notmuch_database_{set,get}_config"
60 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG}
62 EXPECT0(notmuch_database_set_config (db, "test.key1", "testvalue1"));
63 EXPECT0(notmuch_database_set_config (db, "test.key2", "testvalue2"));
64 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
65 printf("test.key1 = %s\n", val);
66 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
67 printf("test.key2 = %s\n", val);
72 test.key1 = testvalue1
73 test.key2 = testvalue2
76 test_expect_equal_file EXPECTED OUTPUT
79 test_begin_subtest "notmuch_database_get_config_list: empty list"
80 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
82 notmuch_config_list_t *list;
83 EXPECT0(notmuch_database_get_config_list (db, "nonexistent", &list));
84 printf("valid = %d\n", notmuch_config_list_valid (list));
85 notmuch_config_list_destroy (list);
93 test_expect_equal_file EXPECTED OUTPUT
95 test_begin_subtest "notmuch_database_get_config_list: closed db"
96 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
98 notmuch_config_list_t *list;
99 EXPECT0(notmuch_database_close (db));
100 stat = notmuch_database_get_config_list (db, "nonexistent", &list);
101 printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
104 cat <<'EOF' >EXPECTED
109 test_expect_equal_file EXPECTED OUTPUT
111 test_begin_subtest "notmuch_database_get_config_list: all pairs"
112 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
114 notmuch_config_list_t *list;
115 EXPECT0(notmuch_database_set_config (db, "zzzafter", "afterval"));
116 EXPECT0(notmuch_database_set_config (db, "aaabefore", "beforeval"));
117 EXPECT0(notmuch_database_get_config_list (db, "", &list));
118 for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
119 printf("%s %s\n", notmuch_config_list_key (list), notmuch_config_list_value(list));
121 notmuch_config_list_destroy (list);
124 cat <<'EOF' >EXPECTED
132 test_expect_equal_file EXPECTED OUTPUT
134 test_begin_subtest "notmuch_database_get_config_list: all pairs (closed db)"
135 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
137 notmuch_config_list_t *list;
138 EXPECT0(notmuch_database_get_config_list (db, "", &list));
139 EXPECT0(notmuch_database_close (db));
140 for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
141 printf("%s %d\n", notmuch_config_list_key (list), NULL == notmuch_config_list_value(list));
143 notmuch_config_list_destroy (list);
146 cat <<'EOF' >EXPECTED
154 test_expect_equal_file EXPECTED OUTPUT
156 test_begin_subtest "notmuch_database_get_config_list: one prefix"
157 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
159 notmuch_config_list_t *list;
160 EXPECT0(notmuch_database_get_config_list (db, "test.key", &list));
161 for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
162 printf("%s %s\n", notmuch_config_list_key (list), notmuch_config_list_value(list));
164 notmuch_config_list_destroy (list);
167 cat <<'EOF' >EXPECTED
173 test_expect_equal_file EXPECTED OUTPUT
175 test_begin_subtest "dump config"
176 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
178 EXPECT0(notmuch_database_set_config (db, "key with spaces", "value, with, spaces!"));
181 notmuch dump --include=config >OUTPUT
182 cat <<'EOF' >EXPECTED
183 #notmuch-dump batch-tag:3 config
184 #@ aaabefore beforeval
185 #@ key%20with%20spaces value,%20with,%20spaces%21
186 #@ test.key1 testvalue1
187 #@ test.key2 testvalue2
190 test_expect_equal_file EXPECTED OUTPUT
192 test_begin_subtest "restore config"
193 notmuch dump --include=config >EXPECTED
194 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
196 EXPECT0(notmuch_database_set_config (db, "test.key1", "mutatedvalue"));
199 notmuch restore --include=config <EXPECTED
200 notmuch dump --include=config >OUTPUT
201 test_expect_equal_file EXPECTED OUTPUT
204 test_begin_subtest "override config from file"
205 notmuch config set test.key1 overridden
206 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG}
208 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
209 printf("test.key1 = %s\n", val);
210 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
211 printf("test.key2 = %s\n", val);
214 cat <<'EOF' >EXPECTED
216 test.key1 = overridden
217 test.key2 = testvalue2
220 test_expect_equal_file EXPECTED OUTPUT
223 test_begin_subtest "NOTMUCH_CONFIG_HOOK_DIR: traditional"
224 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
226 const char *val = notmuch_config_get (db, NOTMUCH_CONFIG_HOOK_DIR);
227 printf("database.hook_dir = %s\n", val);
230 cat <<'EOF' >EXPECTED
232 database.hook_dir = MAIL_DIR/.notmuch/hooks
235 test_expect_equal_file EXPECTED OUTPUT
237 test_begin_subtest "NOTMUCH_CONFIG_HOOK_DIR: xdg"
238 dir="${HOME}/.config/notmuch/default/hooks"
240 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
242 const char *val = notmuch_config_get (db, NOTMUCH_CONFIG_HOOK_DIR);
243 printf("database.hook_dir = %s\n", val);
246 cat <<'EOF' >EXPECTED
248 database.hook_dir = CWD/home/.config/notmuch/default/hooks
252 test_expect_equal_file EXPECTED OUTPUT
254 test_begin_subtest "notmuch_config_get_values"
255 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
257 notmuch_config_values_t *values;
258 EXPECT0(notmuch_config_set (db, NOTMUCH_CONFIG_NEW_TAGS, "a;b;c"));
259 for (values = notmuch_config_get_values (db, NOTMUCH_CONFIG_NEW_TAGS);
260 notmuch_config_values_valid (values);
261 notmuch_config_values_move_to_next (values))
263 puts (notmuch_config_values_get (values));
267 cat <<'EOF' >EXPECTED
274 test_expect_equal_file EXPECTED OUTPUT
277 test_begin_subtest "notmuch_config_get_values_string"
278 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
280 notmuch_config_values_t *values;
281 EXPECT0(notmuch_database_set_config (db, "test.list", "x;y;z"));
282 for (values = notmuch_config_get_values_string (db, "test.list");
283 notmuch_config_values_valid (values);
284 notmuch_config_values_move_to_next (values))
286 puts (notmuch_config_values_get (values));
290 cat <<'EOF' >EXPECTED
297 test_expect_equal_file EXPECTED OUTPUT
300 test_begin_subtest "notmuch_config_get_values (restart)"
301 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
303 notmuch_config_values_t *values;
304 EXPECT0(notmuch_config_set (db, NOTMUCH_CONFIG_NEW_TAGS, "a;b;c"));
305 for (values = notmuch_config_get_values (db, NOTMUCH_CONFIG_NEW_TAGS);
306 notmuch_config_values_valid (values);
307 notmuch_config_values_move_to_next (values))
309 puts (notmuch_config_values_get (values));
311 for (notmuch_config_values_start (values);
312 notmuch_config_values_valid (values);
313 notmuch_config_values_move_to_next (values))
315 puts (notmuch_config_values_get (values));
319 cat <<'EOF' >EXPECTED
329 test_expect_equal_file EXPECTED OUTPUT
333 test_begin_subtest "notmuch_config_get_values, trailing ;"
334 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
336 notmuch_config_values_t *values;
337 EXPECT0(notmuch_config_set (db, NOTMUCH_CONFIG_NEW_TAGS, "a;b;c"));
338 for (values = notmuch_config_get_values (db, NOTMUCH_CONFIG_NEW_TAGS);
339 notmuch_config_values_valid (values);
340 notmuch_config_values_move_to_next (values))
342 puts (notmuch_config_values_get (values));
346 cat <<'EOF' >EXPECTED
353 test_expect_equal_file EXPECTED OUTPUT
357 test_begin_subtest "get config by key"
358 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG}
360 printf("before = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
361 EXPECT0(notmuch_database_set_config (db, "maildir.synchronize_flags", "false"));
362 printf("after = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
365 cat <<'EOF' >EXPECTED
371 test_expect_equal_file EXPECTED OUTPUT
375 test_begin_subtest "set config by key"
376 notmuch config set test.key1 overridden
377 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG}
379 printf("before = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
380 EXPECT0(notmuch_config_set (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS, "false"));
381 printf("after = %s\n", notmuch_config_get (db, NOTMUCH_CONFIG_SYNC_MAILDIR_FLAGS));
384 cat <<'EOF' >EXPECTED
390 test_expect_equal_file EXPECTED OUTPUT
393 test_begin_subtest "load default values"
394 export MAILDIR=${MAIL_DIR}
395 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL%
397 notmuch_config_key_t key;
398 for (key = NOTMUCH_CONFIG_FIRST;
399 key < NOTMUCH_CONFIG_LAST;
400 key = (notmuch_config_key_t)(key + 1)) {
401 const char *val = notmuch_config_get (db, key);
402 printf("%02d: '%s'\n", key, val ? val : "NULL" );
407 _libconfig_sanitize < OUTPUT > OUTPUT.clean
409 cat <<'EOF' >EXPECTED
413 02: 'MAIL_DIR/.notmuch/hooks'
414 03: 'MAIL_DIR/.notmuch/backups'
426 test_expect_equal_file EXPECTED OUTPUT.clean
429 test_begin_subtest "override config from \${NOTMUCH_CONFIG}"
430 notmuch config set test.key1 overridden
431 # second argument omitted to make argv[2] == NULL
432 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
434 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
435 printf("test.key1 = %s\n", val);
436 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
437 printf("test.key2 = %s\n", val);
440 notmuch config set test.key1
441 cat <<'EOF' >EXPECTED
443 test.key1 = overridden
444 test.key2 = testvalue2
447 test_expect_equal_file EXPECTED OUTPUT
451 test_begin_subtest "override config from \${HOME}/.notmuch-config"
452 ovconfig=${HOME}/.notmuch-config
453 cp ${NOTMUCH_CONFIG} ${ovconfig}
454 old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
456 notmuch --config=${ovconfig} config set test.key1 overridden-home
457 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL%
459 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
460 printf("test.key1 = %s\n", val);
461 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
462 printf("test.key2 = %s\n", val);
466 NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
467 cat <<'EOF' >EXPECTED
469 test.key1 = overridden-home
470 test.key2 = testvalue2
473 test_expect_equal_file EXPECTED OUTPUT
477 test_begin_subtest "override config from \${XDG_CONFIG_HOME}/notmuch"
478 ovconfig=${HOME}/.config/notmuch/default/config
479 mkdir -p $(dirname ${ovconfig})
480 cp ${NOTMUCH_CONFIG} ${ovconfig}
481 old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
483 notmuch --config=${ovconfig} config set test.key1 overridden-xdg
484 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL%
486 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
487 printf("test.key1 = %s\n", val);
488 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
489 printf("test.key2 = %s\n", val);
493 NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
494 cat <<'EOF' >EXPECTED
496 test.key1 = overridden-xdg
497 test.key2 = testvalue2
500 test_expect_equal_file EXPECTED OUTPUT
504 test_begin_subtest "override config from \${XDG_CONFIG_HOME}/notmuch with profile"
505 ovconfig=${HOME}/.config/notmuch/work/config
506 mkdir -p $(dirname ${ovconfig})
507 cp ${NOTMUCH_CONFIG} ${ovconfig}
508 old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
510 notmuch --config=${ovconfig} config set test.key1 overridden-xdg-profile
511 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% work
513 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
514 printf("test.key1 = %s\n", val);
515 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
516 printf("test.key2 = %s\n", val);
520 NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
521 cat <<'EOF' >EXPECTED
523 test.key1 = overridden-xdg-profile
524 test.key2 = testvalue2
527 test_expect_equal_file EXPECTED OUTPUT
531 test_begin_subtest "override config from \${HOME}/.notmuch-config.work (via args)"
532 ovconfig=${HOME}/.notmuch-config.work
533 cp ${NOTMUCH_CONFIG} ${ovconfig}
534 old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
536 notmuch --config=${ovconfig} config set test.key1 overridden-profile
537 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% work
539 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
540 printf("test.key1 = %s\n", val);
541 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
542 printf("test.key2 = %s\n", val);
546 NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
547 cat <<'EOF' >EXPECTED
549 test.key1 = overridden-profile
550 test.key2 = testvalue2
553 test_expect_equal_file EXPECTED OUTPUT
556 test_begin_subtest "no config, fail to open database"
557 old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
559 cat c_head - c_tail <<'EOF' | test_C %NULL% '' %NULL%
564 NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
565 cat <<'EOF' >EXPECTED
568 error opening database
570 Error: could not locate database.
573 test_expect_equal_file EXPECTED OUTPUT
575 test_begin_subtest "open database from NOTMUCH_DATABASE"
576 old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
578 export NOTMUCH_DATABASE=${MAIL_DIR}
579 cat c_head - c_tail <<'EOF' | test_C %NULL% '' %NULL%
581 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
582 printf("test.key1 = %s\n", val);
583 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
584 printf("test.key2 = %s\n", val);
587 export NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
588 unset NOTMUCH_DATABASE
589 cat <<'EOF' >EXPECTED
591 test.key1 = testvalue1
592 test.key2 = testvalue2
595 test_expect_equal_file EXPECTED OUTPUT
597 test_begin_subtest "NOTMUCH_DATABASE overrides config"
598 cp notmuch-config notmuch-config.bak
599 notmuch config set database.path /nonexistent
600 export NOTMUCH_DATABASE=${MAIL_DIR}
601 cat c_head - c_tail <<'EOF' | test_C %NULL% '' %NULL%
603 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
604 printf("test.key1 = %s\n", val);
605 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
606 printf("test.key2 = %s\n", val);
609 NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
610 unset NOTMUCH_DATABASE
611 cat <<'EOF' >EXPECTED
613 test.key1 = testvalue1
614 test.key2 = testvalue2
617 cp notmuch-config.bak notmuch-config
618 test_expect_equal_file EXPECTED OUTPUT
623 #include <notmuch-test.h>
625 int main (int argc, char** argv)
627 notmuch_database_t *db;
629 notmuch_status_t stat;
632 for (int i = 1; i < argc; i++)
633 if (strcmp (argv[i], "%NULL%") == 0) argv[i] = NULL;
635 stat = notmuch_database_load_config (argv[1],
640 if (stat != NOTMUCH_STATUS_SUCCESS && stat != NOTMUCH_STATUS_NO_CONFIG) {
641 fprintf (stderr, "error opening database\n%d: %s\n%s\n", stat,
642 notmuch_status_to_string (stat), msg ? msg : "");
648 test_begin_subtest "notmuch_database_get_config (ndlc)"
649 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL%
651 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
652 printf("test.key1 = %s\n", val);
653 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
654 printf("test.key2 = %s\n", val);
657 cat <<'EOF' >EXPECTED
659 test.key1 = testvalue1
660 test.key2 = testvalue2
663 test_expect_equal_file EXPECTED OUTPUT
666 test_begin_subtest "notmuch_database_get_config_list: all pairs (ndlc)"
667 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
669 notmuch_config_list_t *list;
670 EXPECT0(notmuch_database_get_config_list (db, "", &list));
671 for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
672 printf("%s %s\n", notmuch_config_list_key (list), notmuch_config_list_value(list));
674 notmuch_config_list_destroy (list);
677 cat <<'EOF' >EXPECTED
680 key with spaces value, with, spaces!
686 test_expect_equal_file EXPECTED OUTPUT
688 test_begin_subtest "notmuch_database_get_config_list: one prefix (ndlc)"
689 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
691 notmuch_config_list_t *list;
692 EXPECT0(notmuch_database_get_config_list (db, "test.key", &list));
693 for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
694 printf("%s %s\n", notmuch_config_list_key (list), notmuch_config_list_value(list));
696 notmuch_config_list_destroy (list);
699 cat <<'EOF' >EXPECTED
705 test_expect_equal_file EXPECTED OUTPUT
707 test_begin_subtest "list by keys (ndlc)"
708 notmuch config set search.exclude_tags "foo;bar;fub"
709 notmuch config set new.ignore "sekrit_junk"
710 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL%
712 notmuch_config_key_t key;
713 for (key = NOTMUCH_CONFIG_FIRST;
714 key < NOTMUCH_CONFIG_LAST;
715 key = (notmuch_config_key_t)(key + 1)) {
716 const char *val = notmuch_config_get (db, key);
717 printf("%02d: '%s'\n", key, val ? val : "NULL" );
721 cat <<'EOF' >EXPECTED
725 02: 'MAIL_DIR/.notmuch/hooks'
726 03: 'MAIL_DIR/.notmuch/backups'
731 08: 'test_suite@notmuchmail.org'
732 09: 'test_suite_other@notmuchmail.org;test_suite@otherdomain.org'
733 10: 'Notmuch Test Suite'
737 test_expect_equal_file EXPECTED OUTPUT
739 test_begin_subtest "load default values (ndlc, nonexistent config)"
740 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} /nonexistent %NULL%
742 notmuch_config_key_t key;
743 for (key = NOTMUCH_CONFIG_FIRST;
744 key < NOTMUCH_CONFIG_LAST;
745 key = (notmuch_config_key_t)(key + 1)) {
746 const char *val = notmuch_config_get (db, key);
747 printf("%02d: '%s'\n", key, val ? val : "NULL" );
752 _libconfig_sanitize < OUTPUT > OUTPUT.clean
754 cat <<'EOF' >EXPECTED
758 02: 'MAIL_DIR/.notmuch/hooks'
759 03: 'MAIL_DIR/.notmuch/backups'
770 test_expect_equal_file EXPECTED OUTPUT.clean
773 test_begin_subtest "override config from \${HOME}/.notmuch-config (ndlc)"
774 ovconfig=${HOME}/.notmuch-config
775 cp ${NOTMUCH_CONFIG} ${ovconfig}
776 old_NOTMUCH_CONFIG=${NOTMUCH_CONFIG}
778 notmuch --config=${ovconfig} config set test.key1 overridden-home
779 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL%
781 EXPECT0(notmuch_database_get_config (db, "test.key1", &val));
782 printf("test.key1 = %s\n", val);
783 EXPECT0(notmuch_database_get_config (db, "test.key2", &val));
784 printf("test.key2 = %s\n", val);
788 NOTMUCH_CONFIG=${old_NOTMUCH_CONFIG}
789 cat <<'EOF' >EXPECTED
791 test.key1 = overridden-home
792 test.key2 = testvalue2
795 test_expect_equal_file EXPECTED OUTPUT
798 test_begin_subtest "notmuch_config_get_pairs: prefix (ndlc)"
799 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
801 notmuch_config_pairs_t *list;
802 for (list = notmuch_config_get_pairs (db, "user.");
803 notmuch_config_pairs_valid (list);
804 notmuch_config_pairs_move_to_next (list)) {
805 printf("%s %s\n", notmuch_config_pairs_key (list), notmuch_config_pairs_value(list));
807 notmuch_config_pairs_destroy (list);
810 cat <<'EOF' >EXPECTED
812 user.name Notmuch Test Suite
813 user.other_email test_suite_other@notmuchmail.org;test_suite@otherdomain.org
814 user.primary_email test_suite@notmuchmail.org
817 test_expect_equal_file EXPECTED OUTPUT
819 test_begin_subtest "notmuch_config_get_pairs: all pairs (ndlc)"
820 cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL%
822 notmuch_config_pairs_t *list;
823 for (list = notmuch_config_get_pairs (db, "");
824 notmuch_config_pairs_valid (list);
825 notmuch_config_pairs_move_to_next (list)) {
826 printf("%s %s\n", notmuch_config_pairs_key (list), notmuch_config_pairs_value(list));
828 notmuch_config_pairs_destroy (list);
831 cat <<'EOF' >EXPECTED
834 database.autocommit 8000
835 database.backup_dir MAIL_DIR/.notmuch/backups
836 database.hook_dir MAIL_DIR/.notmuch/hooks
837 database.mail_root MAIL_DIR
838 database.path MAIL_DIR
839 key with spaces value, with, spaces!
840 maildir.synchronize_flags true
841 new.ignore sekrit_junk
842 new.tags unread;inbox
843 search.exclude_tags foo;bar;fub
846 user.name Notmuch Test Suite
847 user.other_email test_suite_other@notmuchmail.org;test_suite@otherdomain.org
848 user.primary_email test_suite@notmuchmail.org
852 test_expect_equal_file EXPECTED OUTPUT