2015-06-01 09:09:02 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
test_description="ruby bindings"
|
2017-09-25 23:38:19 +03: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 06:59:15 -05:00
|
|
|
test_ruby() {
|
2021-05-01 06:59:16 -05:00
|
|
|
(
|
2021-05-01 06:59:18 -05:00
|
|
|
cat <<-EOF
|
2021-05-01 06:59:16 -05:00
|
|
|
require 'notmuch'
|
2021-05-01 06:59:18 -05:00
|
|
|
@db = Notmuch::Database.new('$MAIL_DIR')
|
2021-05-01 06:59:16 -05:00
|
|
|
EOF
|
|
|
|
cat
|
2021-05-01 06:59:18 -05:00
|
|
|
) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT
|
2021-05-01 06:59:19 -05:00
|
|
|
test_expect_equal_file EXPECTED OUTPUT
|
2021-05-01 06:59:15 -05:00
|
|
|
}
|
|
|
|
|
2015-06-01 09:09:02 +02:00
|
|
|
test_begin_subtest "compare thread ids"
|
2021-05-01 06:59:19 -05:00
|
|
|
notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
|
|
|
@q = @db.query('tag:inbox')
|
|
|
|
@q.sort = Notmuch::SORT_OLDEST_FIRST
|
2021-05-01 06:59:21 -05:00
|
|
|
@q.search_threads.each do |t|
|
2021-05-01 06:59:20 -05:00
|
|
|
puts t.thread_id
|
2015-06-01 09:09:02 +02:00
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_begin_subtest "compare message ids"
|
2021-05-01 06:59:19 -05:00
|
|
|
notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
|
|
|
@q = @db.query('tag:inbox')
|
|
|
|
@q.sort = Notmuch::SORT_OLDEST_FIRST
|
2021-05-01 06:59:21 -05:00
|
|
|
@q.search_messages.each do |m|
|
2021-05-01 06:59:20 -05:00
|
|
|
puts m.message_id
|
2015-06-01 09:09:02 +02:00
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_begin_subtest "get non-existent file"
|
2021-05-01 06:59:21 -05:00
|
|
|
echo nil > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 06:59:21 -05: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 06:59:19 -05:00
|
|
|
notmuch count --output=messages tag:inbox > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 06:59:21 -05: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 06:59:19 -05:00
|
|
|
notmuch count --output=threads tag:inbox > EXPECTED
|
2015-06-01 09:09:02 +02:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 06:59:21 -05:00
|
|
|
puts @db.query('tag:inbox').count_threads()
|
2015-06-01 09:09:02 +02:00
|
|
|
EOF
|
|
|
|
|
2016-03-06 07:56:28 -04:00
|
|
|
test_begin_subtest "get all tags"
|
2021-05-01 06:59:19 -05:00
|
|
|
notmuch search --output=tags '*' > EXPECTED
|
2016-03-06 07:56:28 -04:00
|
|
|
test_ruby <<"EOF"
|
2021-05-01 06:59:21 -05:00
|
|
|
@db.all_tags.each do |tag|
|
|
|
|
puts tag
|
2016-03-06 07:56:28 -04:00
|
|
|
end
|
|
|
|
EOF
|
|
|
|
|
2015-06-01 09:09:02 +02:00
|
|
|
test_done
|