Skip to content

Commit

Permalink
Fix more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Mar 18, 2024
1 parent 1a7d220 commit 10c24f3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/falcon/service/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the MIT License.
# Copyright, 2020-2023, by Samuel Williams.

require 'async/service/generic'
require_relative 'server'

require 'async/http/endpoint'
require 'async/io/shared_endpoint'
Expand Down
18 changes: 0 additions & 18 deletions lib/falcon/service/virtual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,6 @@ def timeout
# end
end

def redirect_service
hosts = {}

@evaluator.configuration.services do |service|
if service.is_a?(Service::Server)
hosts[service.authority] = service
end
end

Async::Service::Environment.new(Falcon::Service::Redirect).with(
hosts: hosts,
)
end

def proxy_service

end

def self.included(target)
target.include(Environnment)
end
Expand Down
22 changes: 20 additions & 2 deletions test/falcon/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,30 @@
it "can configurure proxy" do
configuration.load_file(File.expand_path(".configuration/proxy.rb", __dir__))

expect(configuration.environments).to be(:include?, 'localhost')
expect(configuration.environments).to be(:any?)

environment = configuration.environments.first
evaluator = environment.evaluator

expect(evaluator).to have_attributes(
service_class: be == Falcon::Service::Proxy,
authority: be == "localhost",
url: be == "https://www.google.com"
)
end

it "can configure rack" do
configuration.load_file(File.expand_path(".configuration/rack.rb", __dir__))

expect(configuration.environments).to be(:include?, 'localhost')
expect(configuration.environments).to be(:any?)

environment = configuration.environments.first
evaluator = environment.evaluator

expect(evaluator).to have_attributes(
service_class: be == Falcon::Service::Server,
authority: be == "localhost",
count: be == 3
)
end
end
5 changes: 2 additions & 3 deletions test/falcon/middleware/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
require 'sus/fixtures/async'
require 'async/http/client'
require 'async/http/endpoint'
require 'async/service/environment'

describe Falcon::Middleware::Proxy do
include Sus::Fixtures::Async::ReactorContext

def proxy_for(**options)
Falcon::Service::Proxy.new(
Async::Service::Environment.build(**options)
)
Async::Service::Environment.build(**options).evaluator
end

let(:proxy) do
Expand Down

0 comments on commit 10c24f3

Please sign in to comment.