2 test_description="ruby bindings"
3 . $(dirname "$0")/test-lib.sh || exit 1
5 if [ "${NOTMUCH_HAVE_RUBY_DEV}" = "0" ]; then
6 test_subtest_missing_external_prereq_["ruby development files"]=t
11 test_begin_subtest "compare thread ids"
14 $maildir = ENV['MAIL_DIR']
16 abort('environment variable MAIL_DIR must be set')
18 @db = Notmuch::Database.new($maildir)
19 @q = @db.query('tag:inbox')
20 @q.sort = Notmuch::SORT_OLDEST_FIRST
21 for t in @q.search_threads do
22 print t.thread_id, "\n"
25 notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
26 test_expect_equal_file EXPECTED OUTPUT
28 test_begin_subtest "compare message ids"
31 $maildir = ENV['MAIL_DIR']
33 abort('environment variable MAIL_DIR must be set')
35 @db = Notmuch::Database.new($maildir)
36 @q = @db.query('tag:inbox')
37 @q.sort = Notmuch::SORT_OLDEST_FIRST
38 for m in @q.search_messages do
39 print m.message_id, "\n"
42 notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
43 test_expect_equal_file EXPECTED OUTPUT
45 test_begin_subtest "get non-existent file"
48 $maildir = ENV['MAIL_DIR']
50 abort('environment variable MAIL_DIR must be set')
52 @db = Notmuch::Database.new($maildir)
53 result = @db.find_message_by_filename('i-dont-exist')
56 test_expect_equal "$(cat OUTPUT)" "true"
58 test_begin_subtest "count messages"
61 $maildir = ENV['MAIL_DIR']
63 abort('environment variable MAIL_DIR must be set')
65 @db = Notmuch::Database.new($maildir)
66 @q = @db.query('tag:inbox')
67 print @q.count_messages(),"\n"
69 notmuch count --output=messages tag:inbox > EXPECTED
70 test_expect_equal_file EXPECTED OUTPUT
72 test_begin_subtest "count threads"
75 $maildir = ENV['MAIL_DIR']
77 abort('environment variable MAIL_DIR must be set')
79 @db = Notmuch::Database.new($maildir)
80 @q = @db.query('tag:inbox')
81 print @q.count_threads(),"\n"
83 notmuch count --output=threads tag:inbox > EXPECTED
84 test_expect_equal_file EXPECTED OUTPUT
86 test_begin_subtest "get all tags"
89 $maildir = ENV['MAIL_DIR']
91 abort('environment variable MAIL_DIR must be set')
93 @db = Notmuch::Database.new($maildir)
99 notmuch search --output=tags '*' > EXPECTED
100 test_expect_equal_file EXPECTED OUTPUT