aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-11-03 19:40:20 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-11-03 19:40:20 +0900
commit9e5c7c3d4fa100574e7f77c06998859ef0deb389 (patch)
tree35d39efa04310441c32fa22a43dc7687ea07ccdf
parentb8778f7bcb4f872d4781ab210b18f72015757789 (diff)
downloadplum-9e5c7c3d4fa100574e7f77c06998859ef0deb389.tar.gz
frame_factory: add tests
-rw-r--r--test/plum/client/test_connection.rb1
-rw-r--r--test/plum/test_frame_factory.rb37
2 files changed, 38 insertions, 0 deletions
diff --git a/test/plum/client/test_connection.rb b/test/plum/client/test_connection.rb
index b539d77..204eb3a 100644
--- a/test/plum/client/test_connection.rb
+++ b/test/plum/client/test_connection.rb
@@ -7,5 +7,6 @@ class ClientConnectionTest < Minitest::Test
stream = con.open_stream(weight: 256)
assert(stream.id % 2 == 1)
assert_equal(256, stream.weight)
+ assert_equal(:idle, stream.state)
end
end
diff --git a/test/plum/test_frame_factory.rb b/test/plum/test_frame_factory.rb
index ff8e67f..ccaa56c 100644
--- a/test/plum/test_frame_factory.rb
+++ b/test/plum/test_frame_factory.rb
@@ -53,4 +53,41 @@ class FrameFactoryTest < Minitest::Test
flags: [:ack],
payload: "12345678")
end
+
+ def test_continuation
+ frame = Frame.continuation(123, "abc", :end_headers)
+ assert_frame(frame,
+ type: :continuation,
+ stream_id: 123,
+ flags: [:end_headers],
+ payload: "abc")
+ end
+
+ def test_data
+ frame = Frame.data(123, "abc".force_encoding("UTF-8"))
+ assert_frame(frame,
+ type: :data,
+ stream_id: 123,
+ flags: [],
+ payload: "abc")
+ assert_equal(Encoding::BINARY, frame.payload.encoding)
+ end
+
+ def test_headers
+ frame = Frame.headers(123, "abc", :end_stream)
+ assert_frame(frame,
+ type: :headers,
+ stream_id: 123,
+ flags: [:end_stream],
+ payload: "abc")
+ end
+
+ def test_push_promise
+ frame = Frame.push_promise(345, 2, "abc", :end_headers)
+ assert_frame(frame,
+ type: :push_promise,
+ stream_id: 345,
+ flags: [:end_headers],
+ payload: "\x00\x00\x00\x02abc")
+ end
end