aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-01-24 14:51:02 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-01-26 14:08:18 +0900
commitc237ea8d6672617e86afc132ca9e06b1013ac1c1 (patch)
tree19e86ef7f01c09b6233fe65e6b219db2fc522cc5 /test/utils
parent9190801a092d46c7079ccee201b212b2d7985952 (diff)
downloadplum-restart.tar.gz
Cleanup projectrestart
Switch test framework, remove unnecessary files, remove unnecessary magic comments.
Diffstat (limited to 'test/utils')
-rw-r--r--test/utils/assertions.rb3
-rw-r--r--test/utils/client.rb19
-rw-r--r--test/utils/server.rb62
3 files changed, 1 insertions, 83 deletions
diff --git a/test/utils/assertions.rb b/test/utils/assertions.rb
index 746d475..ee74523 100644
--- a/test/utils/assertions.rb
+++ b/test/utils/assertions.rb
@@ -1,4 +1,4 @@
-module CustomAssertions
+module Test::Unit::Assertions
def assert_connection_error(type, &blk)
assert_http_error(Plum::RemoteConnectionError, type, &blk)
end
@@ -36,7 +36,6 @@ module CustomAssertions
assert_equal(type, last, "#{klass.name} type: #{type} expected but type: #{last} was raised.")
end
end
-Minitest::Test.__send__(:prepend, CustomAssertions)
module LastErrorExtension
def initialize(type, message = nil)
diff --git a/test/utils/client.rb b/test/utils/client.rb
deleted file mode 100644
index ae8ca16..0000000
--- a/test/utils/client.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require "timeout"
-
-module ServerUtils
- def open_client_connection(scheme = :https)
- io = StringIO.new
- @_ccon = ClientConnection.new(io.method(:write))
- @_ccon << Frame::Settings.ack.assemble
- @_ccon << Frame::Settings.new.assemble
- if block_given?
- yield @_ccon
- else
- @_ccon
- end
- end
-end
-
-class Minitest::Test
- include ServerUtils
-end
diff --git a/test/utils/server.rb b/test/utils/server.rb
deleted file mode 100644
index 001a3fe..0000000
--- a/test/utils/server.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require "timeout"
-
-module ServerUtils
- def open_server_connection(scheme = :https)
- @_io = StringIO.new
- @_con = (scheme == :https ? ServerConnection : HTTPServerConnection).new(@_io.method(:write))
- @_con << Connection::CLIENT_CONNECTION_PREFACE
- @_con << Frame::Settings.new.assemble
- if block_given?
- yield @_con
- else
- @_con
- end
- end
-
- def open_new_stream(arg1 = nil, state: :idle, **kwargs)
- if arg1.is_a?(ServerConnection)
- con = arg1
- else
- con = open_server_connection
- end
-
- @_stream = con.instance_eval { stream(@max_stream_ids[1] + 2) }
- @_stream.set_state(state)
- @_stream.update_dependency(**kwargs)
- if block_given?
- yield @_stream
- else
- @_stream
- end
- end
-
- def sent_frames(io = nil)
- resp = (io || @_io).string.dup.force_encoding(Encoding::BINARY)
- frames = []
- while f = Frame.parse!(resp)
- frames << f
- end
- frames
- end
-
- def parse_frames(io, &blk)
- pos = io.string.bytesize
- blk.call
- resp = io.string.byteslice(pos, io.string.bytesize - pos).force_encoding(Encoding::BINARY)
- frames = []
- while f = Frame.parse!(resp)
- frames << f
- end
- frames
- end
-
- def parse_frame(io, &blk)
- frames = capture_frames(io, &blk)
- assert_equal(1, frames.size, "Supplied block sent no frames or more than 1 frame")
- frames.first
- end
-end
-
-class Minitest::Test
- include ServerUtils
-end