Skip to content

Commit

Permalink
Merge pull request #135 from Earlopain/port-tests
Browse files Browse the repository at this point in the history
Port some tests
  • Loading branch information
casperisfine authored Jun 17, 2024
2 parents 79ba8e9 + 81ec2cd commit 846415a
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 137 deletions.
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
File renamed without changes.
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

0 comments on commit 846415a

Please sign in to comment.