clarify startup message in test mode (#687)

This commit is contained in:
Abdullah Alhusaini 2024-07-30 12:44:38 +03:00 committed by GitHub
parent 0afbd129f5
commit 3243b8e0e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -26,7 +26,7 @@ describe "Run" do
end end
it "runs without a block being specified" do it "runs without a block being specified" do
run(<<-CR).should eq "[test] Kemal is ready to lead at http://0.0.0.0:3000\ntrue\n" run(<<-CR).should contain "[test] Kemal is running in test mode."
Kemal.config.env = "test" Kemal.config.env = "test"
Kemal.run Kemal.run
puts Kemal.config.running puts Kemal.config.running
@ -34,7 +34,7 @@ describe "Run" do
end end
it "allows custom HTTP::Server bind" do it "allows custom HTTP::Server bind" do
run(<<-CR).should eq "[test] Kemal is ready to lead at http://127.0.0.1:3000, http://0.0.0.0:3001\n" run(<<-CR).should contain "[test] Kemal is running in test mode."
Kemal.config.env = "test" Kemal.config.env = "test"
Kemal.run do |config| Kemal.run do |config|
server = config.server.not_nil! server = config.server.not_nil!

View file

@ -66,8 +66,12 @@ module Kemal
end end
def self.display_startup_message(config, server) def self.display_startup_message(config, server)
addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" } if config.env != "test"
log "[#{config.env}] #{config.app_name} is ready to lead at #{addresses}" addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" }
log "[#{config.env}] #{config.app_name} is ready to lead at #{addresses}"
else
log "[#{config.env}] #{config.app_name} is running in test mode. Server not listening"
end
end end
def self.stop def self.stop