diff options
author | Azul <azul@riseup.net> | 2016-05-25 13:13:30 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-05-25 14:13:30 +0200 |
commit | 8a81429f0eb8aa5041d47557d0c5b5359bb959e6 (patch) | |
tree | 10f5d3db69883c685408edc3365d1e762f13e322 /test/unit/couch_db | |
parent | 5c0fa0fb7b10820f2956807cb457421bf1e00708 (diff) |
copy over all files from rewritten attempt
I started a nickserver from scratch to implement the things that are independent of our choice of stack (eventmachine or other).
This commit copies them over and tests both things in parallel.
Diffstat (limited to 'test/unit/couch_db')
-rw-r--r-- | test/unit/couch_db/response_test.rb | 30 | ||||
-rw-r--r-- | test/unit/couch_db/source_unit_test.rb | 17 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/unit/couch_db/response_test.rb b/test/unit/couch_db/response_test.rb new file mode 100644 index 0000000..d44760d --- /dev/null +++ b/test/unit/couch_db/response_test.rb @@ -0,0 +1,30 @@ +require 'test_helper' +require 'file_content' +require 'nickserver/couch_db/response' + +class Nickserver::CouchDB::ResponseTest < Minitest::Test + include FileContent + + def test_404 + response = response_for "bananas@example.org", + status: 404, body: "{}" + assert_equal 404, response.status + end + + def test_200_with_empty_response + response = response_for "stompy@example.org", + status: 200, body: file_content(:empty_couchdb_result) + assert_equal 404, response.status + end + + def test_200_with_success + response = response_for "blue@example.org", + status: 200, body: file_content(:blue_couchdb_result) + assert_equal 200, response.status + assert_equal file_content(:blue_nickserver_result), response.content + end + + def response_for(uid, couch_response = {}) + Nickserver::CouchDB::Response.new uid, couch_response + end +end diff --git a/test/unit/couch_db/source_unit_test.rb b/test/unit/couch_db/source_unit_test.rb new file mode 100644 index 0000000..19ea9bc --- /dev/null +++ b/test/unit/couch_db/source_unit_test.rb @@ -0,0 +1,17 @@ +require 'test_helper' +require 'nickserver/couch_db/source' + +module Nickserver::CouchDB + class SourceUnitTest < Minitest::Test + + def test_query + address = "nick@domain.tl" + adapter = Minitest::Mock.new + adapter.expect :get, nil, + [String, {query: { reduce: "false", key: "\"#{address}\"" }}] + query = Source.new(adapter) + query.query address + adapter.verify + end + end +end |