aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-11-03 19:33:39 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-11-03 19:33:39 +0900
commitb8778f7bcb4f872d4781ab210b18f72015757789 (patch)
tree0d65d38923a825cd11005f6b85f2903167cf3d51 /test
parentb954d7b52f6398cd4bf759a014e2754aa349e220 (diff)
downloadplum-b8778f7bcb4f872d4781ab210b18f72015757789.tar.gz
client/connection: add test for ClientConnection#open_stream
Diffstat (limited to 'test')
-rw-r--r--test/plum/client/test_connection.rb11
-rw-r--r--test/plum/test_connection.rb1
-rw-r--r--test/plum/test_stream_utils.rb1
-rw-r--r--test/utils/client.rb19
4 files changed, 30 insertions, 2 deletions
diff --git a/test/plum/client/test_connection.rb b/test/plum/client/test_connection.rb
new file mode 100644
index 0000000..b539d77
--- /dev/null
+++ b/test/plum/client/test_connection.rb
@@ -0,0 +1,11 @@
+require "test_helper"
+
+using Plum::BinaryString
+class ClientConnectionTest < Minitest::Test
+ def test_open_stream
+ con = open_client_connection
+ stream = con.open_stream(weight: 256)
+ assert(stream.id % 2 == 1)
+ assert_equal(256, stream.weight)
+ end
+end
diff --git a/test/plum/test_connection.rb b/test/plum/test_connection.rb
index 4c9668b..6ab63ed 100644
--- a/test/plum/test_connection.rb
+++ b/test/plum/test_connection.rb
@@ -23,7 +23,6 @@ class ConnectionTest < Minitest::Test
con << Frame.new(type: :settings, stream_id: 0, payload: _settings * (limit / 6 + 1)).assemble
}
}
-
new_con.call {|con|
assert_connection_error(:frame_size_error) {
con << Frame.new(type: :headers, stream_id: 3, payload: "\x00" * (limit + 1)).assemble
diff --git a/test/plum/test_stream_utils.rb b/test/plum/test_stream_utils.rb
index c230bf2..363fcf8 100644
--- a/test/plum/test_stream_utils.rb
+++ b/test/plum/test_stream_utils.rb
@@ -1,7 +1,6 @@
require "test_helper"
using BinaryString
-
class StreamUtilsTest < Minitest::Test
def test_stream_promise
open_new_stream {|stream|
diff --git a/test/utils/client.rb b/test/utils/client.rb
new file mode 100644
index 0000000..be8d78d
--- /dev/null
+++ b/test/utils/client.rb
@@ -0,0 +1,19 @@
+require "timeout"
+
+module ServerUtils
+ def open_client_connection(scheme = :https)
+ io = StringIO.new
+ @_ccon = ClientConnection.new(io.method(:write))
+ @_ccon << Frame.new(type: :settings, stream_id: 0, flags: [:ack]).assemble
+ @_ccon << Frame.new(type: :settings, stream_id: 0).assemble
+ if block_given?
+ yield @_ccon
+ else
+ @_ccon
+ end
+ end
+end
+
+class Minitest::Test
+ include ServerUtils
+end