unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Pieter Praet <pieter@praet.org>
To: David Bremner <david@tethera.net>,
	Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
Cc: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH] test: cli: getting/setting/removing config values
Date: Thu, 12 Jan 2012 18:30:01 +0100	[thread overview]
Message-ID: <1326389401-20468-1-git-send-email-pieter@praet.org> (raw)
In-Reply-To: <87y5tckf1y.fsf@praet.org>

Should have come before commit 1df71b55

---
 test/config       |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/notmuch-test |    1 +
 2 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 test/config

diff --git a/test/config b/test/config
new file mode 100755
index 0000000..ee3126c
--- /dev/null
+++ b/test/config
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+test_description='notmuch config'
+. ./test-lib.sh
+
+
+config_options=(
+    "database.path"
+    "user.name"
+    "user.primary_email"
+    "user.other_email"
+    "new.tags"
+    "maildir.synchronize_flags"
+)
+
+
+test_begin_subtest 'getting config: "config get <section>.<item>"'
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+    notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <<EOF
+${MAIL_DIR}
+Notmuch Test Suite
+test_suite@notmuchmail.org
+test_suite_other@notmuchmail.org
+test_suite@otherdomain.org
+unread
+inbox
+true
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
+
+test_begin_subtest 'setting config: "config set <section>.<item> [values ...]"'
+notmuch config set database.path /path/to/maildir
+notmuch config set user.name "User Name"
+notmuch config set user.primary_email primary_email@notmuchmail.org
+notmuch config set user.other_email alt1@notmuchmail.org alt2@notmuchmail.org
+notmuch config set new.tags tag1 tag2 tag3
+notmuch config set maildir.synchronize_flags false
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+    notmuch config get "${i}"
+done >> OUTPUT
+cat >EXPECTED <<EOF
+/path/to/maildir
+User Name
+primary_email@notmuchmail.org
+alt1@notmuchmail.org
+alt2@notmuchmail.org
+tag1
+tag2
+tag3
+false
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
+
+test_begin_subtest 'removing config: "config set <section>.<item>"'
+notmuch config set database.path
+notmuch config set user.name
+notmuch config set user.primary_email
+notmuch config set user.other_email
+notmuch config set new.tags
+notmuch config set maildir.synchronize_flags
+echo -n "" > OUTPUT
+for i in ${config_options[*]} ; do
+    notmuch config get "${i}"
+done >> OUTPUT
+
+# FIXME: Not the most robust nor portable solution here...
+# Especially `hostname --domain' may have unwanted effects on
+# some platforms, e.g. setting your hostname to "--domain" ;)
+fallback_name="$(grep $(id -un) /etc/passwd | cut -d ":" -f 5 | cut -d "," -f 1)"
+fallback_email="$(id -un)@$(hostname).$(hostname --domain)"
+
+cat >EXPECTED <<EOF
+${HOME}/mail
+${fallback_name}
+${fallback_email}
+unread
+inbox
+true
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
+
+test_done
diff --git a/test/notmuch-test b/test/notmuch-test
index e40ef86..f0c1d7c 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -18,6 +18,7 @@ cd $(dirname "$0")
 
 TESTS="
   basic
+  config
   help-test
   new
   count
-- 
1.7.8.1

  reply	other threads:[~2012-01-12 17:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-10 17:50 [RFC PATCH] cli: factor out config handling code to get/set lists David Bremner
2011-12-10 18:24 ` Austin Clements
2011-12-10 20:30   ` David Bremner
2011-12-11 16:07     ` [PATCH] " David Bremner
2011-12-11 16:41       ` Dmitry Kurochkin
2011-12-12 18:26         ` David Bremner
2012-01-12 17:26           ` Pieter Praet
2012-01-12 17:30             ` Pieter Praet [this message]
2012-01-13  3:42               ` [PATCH] test: cli: getting/setting/removing config values David Bremner
2012-01-14  8:54                 ` Pieter Praet
2012-01-14  8:57                   ` Pieter Praet
2012-01-14 12:16                     ` David Bremner
2012-01-16 10:31                       ` Pieter Praet
2012-01-16 11:37                         ` David Bremner
2012-01-16 16:48                           ` Pieter Praet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1326389401-20468-1-git-send-email-pieter@praet.org \
    --to=pieter@praet.org \
    --cc=david@tethera.net \
    --cc=dmitry.kurochkin@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).