Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port some tests #135

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/integration/apps/rack_input_class.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

app = lambda do |env|
[ 200, {}, [env["rack.input"].class.name] ]
end
run app
24 changes: 0 additions & 24 deletions test/integration/t0013-rewindable-input-false.sh

This file was deleted.

13 changes: 0 additions & 13 deletions test/integration/t0013.ru

This file was deleted.

24 changes: 0 additions & 24 deletions test/integration/t0014-rewindable-input-true.sh

This file was deleted.

13 changes: 0 additions & 13 deletions test/integration/t0014.ru

This file was deleted.

25 changes: 0 additions & 25 deletions test/integration/t0015-configurator-internals.sh

This file was deleted.

23 changes: 0 additions & 23 deletions test/integration/t0018-write-on-close.sh

This file was deleted.

14 changes: 0 additions & 14 deletions test/integration/t0301.ru

This file was deleted.

22 changes: 21 additions & 1 deletion test/integration/test_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_listen_queues
addr, port = unused_port

pid = spawn_server(app: File.join(ROOT, "test/integration/env.ru"), config: <<~CONFIG)
listen "#{addr}:#{port}", queues: 2, workers_per_queue: 1
listen "#{addr}:#{port}", queues: 2, queues_per_worker: 1
worker_processes 2
CONFIG

Expand All @@ -153,4 +153,24 @@ def test_listen_queues

assert_clean_shutdown(pid)
end

def test_modify_internals
addr, port = unused_port

pid = spawn_server(app: File.join(ROOT, "test/integration/env.ru"), config: <<~CONFIG)
listen "#{addr}:#{port}", queues: 1
worker_processes 1

HttpParser::DEFAULTS["rack.url_scheme"] = "https"
Configurator::DEFAULTS[:logger].progname = "[FOO]"
CONFIG

assert_healthy("http://#{addr}:#{port}")

env = Net::HTTP.get(URI("http://#{addr}:#{port}/"))
assert_match('"rack.url_scheme"=>"https"', env)
assert_stderr(/\[FOO\]/)

assert_clean_shutdown(pid)
end
end
16 changes: 16 additions & 0 deletions test/integration/test_http_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,20 @@ def test_streaming_body

assert_clean_shutdown(pid)
end

def test_write_on_close
addr, port = unused_port

pid = spawn_server(app: File.join(ROOT, "test/integration/apps/write-on-close.ru"), config: <<~CONFIG)
listen "#{addr}:#{port}"
worker_processes 1
CONFIG

assert_healthy("http://#{addr}:#{port}")

response = Net::HTTP.get_response(URI("http://#{addr}:#{port}"))
assert_equal "Goodbye", response.body

assert_clean_shutdown(pid)
end
end
40 changes: 40 additions & 0 deletions test/integration/test_rewindable_input_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true
require "integration_test_helper"

class RewindableInputTest < Pitchfork::IntegrationTest
def test_rewindable_input_false
addr, port = unused_port

pid = spawn_server(app: File.join(ROOT, "test/integration/apps/rack_input_class.ru"), lint: false, config: <<~CONFIG)
listen "#{addr}:#{port}"
worker_processes 1

rewindable_input false
CONFIG

assert_healthy("http://#{addr}:#{port}")

http = Net::HTTP.new(addr, port)
assert_equal "Pitchfork::StreamInput", http.send_request("PUT", "/", "foo").body

assert_clean_shutdown(pid)
end

def test_rewindable_input_true
addr, port = unused_port

pid = spawn_server(app: File.join(ROOT, "test/integration/apps/rack_input_class.ru"), lint: false, config: <<~CONFIG)
listen "#{addr}:#{port}"
worker_processes 1

rewindable_input true
CONFIG

assert_healthy("http://#{addr}:#{port}")

http = Net::HTTP.new(addr, port)
assert_equal "Pitchfork::TeeInput", http.send_request("PUT", "/", "foo").body

assert_clean_shutdown(pid)
end
end
Loading