From 10c24f3da8aa4a4851e4ee221db27e2304472b2d Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Mon, 18 Mar 2024 20:43:49 +1300 Subject: [PATCH] Fix more tests. --- lib/falcon/service/proxy.rb | 2 +- lib/falcon/service/virtual.rb | 18 ------------------ test/falcon/configuration.rb | 22 ++++++++++++++++++++-- test/falcon/middleware/proxy.rb | 5 ++--- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/falcon/service/proxy.rb b/lib/falcon/service/proxy.rb index 90121ea5..0ed98218 100644 --- a/lib/falcon/service/proxy.rb +++ b/lib/falcon/service/proxy.rb @@ -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' diff --git a/lib/falcon/service/virtual.rb b/lib/falcon/service/virtual.rb index fa948243..52a4ee64 100644 --- a/lib/falcon/service/virtual.rb +++ b/lib/falcon/service/virtual.rb @@ -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 diff --git a/test/falcon/configuration.rb b/test/falcon/configuration.rb index 2a493249..5a6204d7 100644 --- a/test/falcon/configuration.rb +++ b/test/falcon/configuration.rb @@ -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 diff --git a/test/falcon/middleware/proxy.rb b/test/falcon/middleware/proxy.rb index 48831b9a..50ec17b0 100644 --- a/test/falcon/middleware/proxy.rb +++ b/test/falcon/middleware/proxy.rb @@ -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