diff options
author | Azul <azul@riseup.net> | 2016-07-02 12:03:46 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-07-02 12:03:46 +0200 |
commit | fb2d7e6f8f1fceefbc8964d34369a867eb8f25bb (patch) | |
tree | 672ea8bbf03876d65c90ecb1ed152424e74939e1 /test/unit/hkp | |
parent | 8a664a39bc3dd77a9c53fa5931f81c2b2b8b7295 (diff) |
refactor: replace blocks/yields with returns
This became possible because we now use celluloid.
Celluloid handles asynchronity without the need for callbacks
or blocks.
Diffstat (limited to 'test/unit/hkp')
-rw-r--r-- | test/unit/hkp/client_test.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/unit/hkp/client_test.rb b/test/unit/hkp/client_test.rb new file mode 100644 index 0000000..9784d0a --- /dev/null +++ b/test/unit/hkp/client_test.rb @@ -0,0 +1,53 @@ +require 'test_helper' +require 'nickserver/hkp/client' + +module Nickserver::Hkp + class ClientTest < Minitest::Test + + def test_get_key_infos_by_email + adapter_expects_query op: "vindex", + search: email, + options: "mr", + fingerprint: "on", + exact: "on" + client.get_key_infos_by_email(email) + @adapter.verify + end + + def test_key_by_fingerprint + adapter_expects_query op: "get", + search: "0x#{fingerprint}", + options: "mr", + exact: "on" + client.get_key_by_fingerprint(fingerprint) + @adapter.verify + end + + def client + @client ||= Client.new @adapter + end + + def adapter_expects_query(query = {}) + adapter_expects Nickserver::Config.hkp_url, query: query + end + + def adapter_expects(*args) + @adapter = Minitest::Mock.new + @adapter.expect :get, dummy_response, + args + end + + def email + 'dummy_email' + end + + def fingerprint + 'dummy_fingerprint' + end + + def dummy_response + [200, 'dummy_response'] + end + + end +end |