2015-06-01 09:09:02 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
test_description="ruby bindings"
|
2017-09-25 22:38:19 +02:00
|
|
|
. $(dirname "$0")/test-lib.sh || exit 1
|
2015-06-01 09:09:02 +02:00
|
|
|
|
|
|
|
if [ "${NOTMUCH_HAVE_RUBY_DEV}" = "0" ]; then
|
|
|
|
test_subtest_missing_external_prereq_["ruby development files"]=t
|
|
|
|
fi
|
|
|
|
|
|
|
|
add_email_corpus
|
|
|
|
|
2021-05-01 13:59:15 +02:00
|
|
|
test_ruby() {
|
2021-05-01 13:59:16 +02:00
|
|
|
(
|
2021-05-01 13:59:18 +02:00
|
|
|
cat <<-EOF
|
2021-05-01 13:59:16 +02:00
|
|
|
require 'notmuch'
|
2021-05-01 13:59:22 +02:00
|
|
|
db = Notmuch::Database.new('$MAIL_DIR')
|
2021-05-01 13:59:16 +02:00
|
|
|
EOF
|
|
|
|
cat
|
2021-05-01 13:59:18 +02:00
|
|
|
) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT
|
2021-05-01 13:59:19 +02:00
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
2021-05-01 13:59:15 +02:00
|
|
|
}
|
|
|
|
|
2015-06-01 09:09:02 +02:00
|
|
|
test_begin_subtest "compare thread ids"
|
2021-05-01 13:59:23 +02:00
|
|
|
notmuch search --sort=oldest-first --output=threads tag:inbox > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 13:59:22 +02:00
|
|
|
q = db.query('tag:inbox')
|
|
|
|
q.sort = Notmuch::SORT_OLDEST_FIRST
|
|
|
|
q.search_threads.each do |t|
|
2021-05-01 13:59:23 +02:00
|
|
|
puts 'thread:%s' % t.thread_id
|
2015-06-01 09:09:02 +02:00
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_begin_subtest "compare message ids"
|
2021-05-01 13:59:23 +02:00
|
|
|
notmuch search --sort=oldest-first --output=messages tag:inbox > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 13:59:22 +02:00
|
|
|
q = db.query('tag:inbox')
|
|
|
|
q.sort = Notmuch::SORT_OLDEST_FIRST
|
|
|
|
q.search_messages.each do |m|
|
2021-05-01 13:59:23 +02:00
|
|
|
puts 'id:%s' % m.message_id
|
2015-06-01 09:09:02 +02:00
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_begin_subtest "get non-existent file"
|
2021-05-01 13:59:21 +02:00
|
|
|
echo nil > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 13:59:22 +02:00
|
|
|
p db.find_message_by_filename('i-dont-exist')
|
2015-06-01 09:09:02 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_begin_subtest "count messages"
|
2021-05-01 13:59:19 +02:00
|
|
|
notmuch count --output=messages tag:inbox > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 13:59:22 +02:00
|
|
|
puts db.query('tag:inbox').count_messages()
|
2015-06-01 09:09:02 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_begin_subtest "count threads"
|
2021-05-01 13:59:19 +02:00
|
|
|
notmuch count --output=threads tag:inbox > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 13:59:22 +02:00
|
|
|
puts db.query('tag:inbox').count_threads()
|
2015-06-01 09:09:02 +02:00
|
|
|
EOF
|
|
|
|
|
2016-03-06 12:56:28 +01:00
|
|
|
test_begin_subtest "get all tags"
|
2021-05-01 13:59:19 +02:00
|
|
|
notmuch search --output=tags '*' > EXPECTED
|
2016-03-06 12:56:28 +01:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 13:59:22 +02:00
|
|
|
db.all_tags.each do |tag|
|
2021-05-01 13:59:21 +02:00
|
|
|
puts tag
|
2016-03-06 12:56:28 +01:00
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
2021-05-01 14:04:46 +02:00
|
|
|
notmuch config set search.exclude_tags deleted
|
|
|
|
generate_message '[subject]="Good"'
|
|
|
|
generate_message '[subject]="Bad"' "[in-reply-to]=\<$gen_msg_id\>"
|
|
|
|
notmuch new > /dev/null
|
|
|
|
notmuch tag +deleted id:$gen_msg_id
|
|
|
|
|
|
|
|
test_begin_subtest "omit excluded all"
|
|
|
|
notmuch search --output=threads --exclude=all tag:inbox > EXPECTED
|
|
|
|
test_ruby <<"EOF"
|
|
|
|
q = db.query('tag:inbox')
|
|
|
|
q.add_tag_exclude('deleted')
|
|
|
|
q.omit_excluded = Notmuch::EXCLUDE_ALL
|
|
|
|
q.search_threads.each do |t|
|
|
|
|
puts 'thread:%s' % t.thread_id
|
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
2015-06-01 09:09:02 +02:00
|
|
|
test_done
|