commit e1bd0af6619b8bfdd514dc3ba5e4dd6af9a08ee6
parent 52f7c16a39ca4f3ec5005a83296e2fcc8fc0403e
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date: Sun, 6 Jun 2010 09:03:04 -0700
add test_query and check tag
Diffstat:
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/test/test_server.rb b/test/test_server.rb
@@ -40,7 +40,7 @@ class QueueingClient < EM::P::RedwoodClient
end
def receive_message type, tag, params
- @q << [type, params]
+ @q << [type, tag, params]
end
def connection_established
@@ -85,14 +85,20 @@ class TestServer < Test::Unit::TestCase
end
def test_invalid_request
- @client.write 'foo', {}
- check @client.read, 'error'
+ @client.write 'foo', '1'
+ check @client.read, 'error', '1'
end
- def check resp, type, args={}
+ def test_query
+ @client.write 'query', '1', 'query' => 'type:mail'
+ check @client.read, 'done', '1'
+ end
+
+ def check resp, type, tag, args={}
assert_equal type.to_s, resp[0]
+ assert_equal tag.to_s, resp[1]
args.each do |k,v|
- assert_equal v, resp[1][k.to_s]
+ assert_equal v, resp[2][k.to_s]
end
end
end