2011-11-08 04:57:11 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
test_description='"notmuch tag"'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
add_message '[subject]=One'
|
|
|
|
add_message '[subject]=Two'
|
|
|
|
|
|
|
|
test_begin_subtest "Adding tags"
|
|
|
|
notmuch tag +tag1 +tag2 +tag3 \*
|
|
|
|
output=$(notmuch search \* | notmuch_search_sanitize)
|
|
|
|
test_expect_equal "$output" "\
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 tag2 tag3 unread)
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 tag3 unread)"
|
|
|
|
|
|
|
|
test_begin_subtest "Removing tags"
|
|
|
|
notmuch tag -tag1 -tag2 \*
|
|
|
|
output=$(notmuch search \* | notmuch_search_sanitize)
|
|
|
|
test_expect_equal "$output" "\
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag3 unread)
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag3 unread)"
|
|
|
|
|
|
|
|
test_expect_code 1 "No tag operations" 'notmuch tag One'
|
|
|
|
test_expect_code 1 "No query" 'notmuch tag +tag2'
|
|
|
|
|
|
|
|
test_begin_subtest "Redundant tagging"
|
|
|
|
notmuch tag +tag1 -tag3 One
|
|
|
|
notmuch tag +tag1 -tag3 \*
|
|
|
|
output=$(notmuch search \* | notmuch_search_sanitize)
|
|
|
|
test_expect_equal "$output" "\
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"
|
|
|
|
|
|
|
|
test_begin_subtest "Special characters in tags"
|
|
|
|
notmuch tag +':" ' \*
|
|
|
|
notmuch tag -':" ' Two
|
|
|
|
output=$(notmuch search \* | notmuch_search_sanitize)
|
|
|
|
test_expect_equal "$output" "\
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 unread)
|
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"
|
|
|
|
|
2012-03-26 23:04:08 +02:00
|
|
|
test_begin_subtest "Tagging order"
|
|
|
|
notmuch tag +tag4 -tag4 One
|
|
|
|
notmuch tag -tag4 +tag4 Two
|
|
|
|
output=$(notmuch search \* | notmuch_search_sanitize)
|
|
|
|
test_expect_equal "$output" "\
|
2012-03-26 23:04:09 +02:00
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 unread)
|
2012-03-26 23:04:08 +02:00
|
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)"
|
|
|
|
|
2012-12-25 20:42:41 +01:00
|
|
|
test_begin_subtest '--batch: checking error messages'
|
|
|
|
notmuch dump --format=batch-tag > BACKUP
|
|
|
|
notmuch tag --batch <<EOF 2>OUTPUT
|
|
|
|
# the next line has a space
|
|
|
|
|
|
|
|
# this line has no tag operations, but this is permitted in batch format.
|
|
|
|
a
|
|
|
|
+0
|
|
|
|
+a +b
|
|
|
|
# trailing whitespace
|
|
|
|
+a +b
|
|
|
|
+c +d --
|
|
|
|
# this is a harmless comment, do not yell about it.
|
|
|
|
|
|
|
|
# the previous line was blank; also no yelling please
|
|
|
|
+%zz -- id:whatever
|
|
|
|
# the next non-comment line should report an an empty tag error for
|
|
|
|
# batch tagging, but not for restore
|
|
|
|
+ +e -- id:foo
|
|
|
|
+- -- id:foo
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat <<EOF > EXPECTED
|
|
|
|
Warning: no query string [+0]
|
|
|
|
Warning: no query string [+a +b]
|
|
|
|
Warning: missing query string [+a +b ]
|
|
|
|
Warning: no query string after -- [+c +d --]
|
|
|
|
Warning: hex decoding of tag %zz failed [+%zz -- id:whatever]
|
|
|
|
Warning: empty tag forbidden [+ +e -- id:foo]
|
|
|
|
Warning: tag starting with '-' forbidden [+- -- id:foo]
|
|
|
|
EOF
|
|
|
|
|
|
|
|
notmuch restore --format=batch-tag < BACKUP
|
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
|
2012-10-26 22:54:12 +02:00
|
|
|
test_expect_code 1 "Empty tag names" 'notmuch tag + One'
|
|
|
|
|
|
|
|
test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'
|
|
|
|
|
2011-11-08 04:57:11 +01:00
|
|
|
test_done
|