]> git.notmuchmail.org Git - notmuch/blob - test/tagging
test: add tests for date:since..until range queries
[notmuch] / test / tagging
1 #!/usr/bin/env bash
2 test_description='"notmuch tag"'
3 . ./test-lib.sh
4
5 add_message '[subject]=One'
6 add_message '[subject]=Two'
7
8 test_begin_subtest "Adding tags"
9 notmuch tag +tag1 +tag2 +tag3 \*
10 output=$(notmuch search \* | notmuch_search_sanitize)
11 test_expect_equal "$output" "\
12 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 tag2 tag3 unread)
13 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 tag3 unread)"
14
15 test_begin_subtest "Removing tags"
16 notmuch tag -tag1 -tag2 \*
17 output=$(notmuch search \* | notmuch_search_sanitize)
18 test_expect_equal "$output" "\
19 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag3 unread)
20 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag3 unread)"
21
22 test_expect_code 1 "No tag operations" 'notmuch tag One'
23 test_expect_code 1 "No query" 'notmuch tag +tag2'
24
25 test_begin_subtest "Redundant tagging"
26 notmuch tag +tag1 -tag3 One
27 notmuch tag +tag1 -tag3 \*
28 output=$(notmuch search \* | notmuch_search_sanitize)
29 test_expect_equal "$output" "\
30 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
31 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"
32
33 test_begin_subtest "Special characters in tags"
34 notmuch tag +':" ' \*
35 notmuch tag -':" ' Two
36 output=$(notmuch search \* | notmuch_search_sanitize)
37 test_expect_equal "$output" "\
38 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 unread)
39 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"
40
41 test_begin_subtest "Tagging order"
42 notmuch tag +tag4 -tag4 One
43 notmuch tag -tag4 +tag4 Two
44 output=$(notmuch search \* | notmuch_search_sanitize)
45 test_expect_equal "$output" "\
46 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 unread)
47 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)"
48
49 test_expect_code 1 "Empty tag names" 'notmuch tag + One'
50
51 test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'
52
53 test_done