diff options
author | elijah <elijah@riseup.net> | 2016-03-29 13:27:01 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2016-04-05 09:52:01 -0700 |
commit | eac3056c237d523f4786593922fe8f88eb65dff7 (patch) | |
tree | 4eb33d64139f65aa1444543d72fbe07dc97314ae /tests/helpers/couchdb_helper.rb | |
parent | 90e1d3ec113d2644b659fd6ed9af7d2b94393407 (diff) |
testing: adds mx delivery tests
Diffstat (limited to 'tests/helpers/couchdb_helper.rb')
-rw-r--r-- | tests/helpers/couchdb_helper.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/helpers/couchdb_helper.rb b/tests/helpers/couchdb_helper.rb index 27dabfcb..b9085c1e 100644 --- a/tests/helpers/couchdb_helper.rb +++ b/tests/helpers/couchdb_helper.rb @@ -103,4 +103,40 @@ class LeapTest end end + def assert_destroy_user_db(user_id, options=nil) + db_name = "user-#{user_id}" + url = couchdb_url("/#{db_name}", options) + http_options = {:ok_codes => [200, 404]} # ignore missing dbs + assert_delete(url, nil, http_options) + end + + def assert_create_user_db(user_id, options=nil) + db_name = "user-#{user_id}" + url = couchdb_url("/#{db_name}", options) + http_options = {:ok_codes => [200, 404]} # ignore missing dbs + assert_put(url, nil, :format => :json) do |body| + assert response = JSON.parse(body), "PUT response should be JSON" + assert response["ok"], "PUT response should be OK" + end + end + + # + # returns true if the per-user db created by soledad-server exists. + # + def user_db_exists?(user_id, options=nil) + db_name = "user-#{user_id}" + url = couchdb_url("/#{db_name}", options) + get(url) do |body, response, error| + if response.nil? + fail "could not query couchdb #{url}: #{error}\n#{body}" + elsif response.code.to_i == 200 + return true + elsif response.code.to_i == 404 + return false + else + fail ["could not query couchdb #{url}: expected response code 200 or 404, but got #{response.code}.", error, body].compact.join("\n") + end + end + end + end
\ No newline at end of file |