From 61441a85b2a96cedd33c7bdc5940f0b8858de7be Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 17 Mar 2016 16:53:33 -0700 Subject: mx test: query identities table for a random record. closes #6406 --- tests/white-box/mx.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index ed990a2e..768b561f 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -31,6 +31,37 @@ class Mx < LeapTest end end + # + # this test picks a random identity document, then queries + # using the by_address view for that same document again. + # + def test_03_Can_query_identities_db? + assert_get(couchdb_url("/identities", url_options)) do |body| + assert response = JSON.parse(body) + doc_count = response['doc_count'].to_i + if doc_count < 1 + skip "There are no identity records yet." + else + offset = rand(doc_count) # pick a random document + count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", url_options) + assert_get(count_url) do |body| + assert response = JSON.parse(body) + record = response['rows'].first + address = record['doc']['address'] + assert address, "address should not be empty" + url_base = %(/identities/_design/Identity/_view/by_address) + params = %(?include_docs=true&reduce=false&startkey="#{address}"&endkey="#{address}") + assert_get(couchdb_url(url_base+params, url_options)) do |body| + assert response = JSON.parse(body) + assert record = response['rows'].first + assert_equal address, record['doc']['address'] + pass + end + end + end + end + end + def test_03_Are_MX_daemons_running? assert_running '.*/usr/bin/twistd.*mx.tac' assert_running '^/usr/lib/postfix/master$' -- cgit v1.2.3