[PATCH 1/4] notmuch-restore: add tests for new --match command line argument.

David Bremner david at tethera.net
Fri Oct 28 20:04:48 PDT 2011


From: David Bremner <bremner at debian.org>

The syntax is notmuch restore --match=regex

We check here that
- missing regex fails
- bad regex fails
- good regex succeeds (at least the command line argument parsing).
---
 test/dump-restore |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/test/dump-restore b/test/dump-restore
index 439e998..c176b52 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -50,9 +50,24 @@ test_expect_success 'Restore with nothing to do, III' \
   test_cmp dump.expected dump.actual'
 
 # notmuch restore currently only considers the first argument.
-test_expect_success 'Invalid restore invocation' \
+test_expect_success 'restore extra argument' \
   'test_must_fail notmuch restore dump.expected another_one'
 
+
+test_begin_subtest 'restore --match #missing arg'
+test_subtest_known_broken
+test_expect_equal "restore: option '--match' requires an argument"\
+  "$(notmuch restore --match 2>&1)"
+
+test_begin_subtest 'restore --match=<bad regex>'
+test_subtest_known_broken
+test_expect_equal 'compiling regex notmuch.*[: Invalid regular expression'\
+  "$(notmuch restore --match='notmuch.*[' 2>&1)"
+
+test_subtest_known_broken
+test_expect_success 'restore --match=<good regex>' \
+    'notmuch restore --match="notmuch.*" < /dev/null > /dev/null 2>&1'
+
 test_begin_subtest "dump outfile"
 notmuch dump dump-outfile.actual
 test_expect_equal_file dump.expected dump-outfile.actual
-- 
1.7.6.3



More information about the notmuch mailing list