Sha256: 486c0ced86e62bb167a8ab991fa0475d802227f34c19b4ffcdd0743c90bc8b6d

Contents?: true

Size: 1 KB

Versions: 93

Compression:

Stored size: 1 KB

Contents

require_relative '../../helper'
require 'flexmock/test_unit'

begin
  require 'fluent/plugin_helper/http_server/router'
  skip = false
rescue LoadError => _
  skip = true
end

unless skip
  class HttpHelperRouterTest < Test::Unit::TestCase
    sub_test_case '#mount' do
      test 'mount with method and path' do
        router = Fluent::PluginHelper::HttpServer::Router.new
        router.mount(:get, '/path/', ->(req) { req })
        assert_equal(router.route!(:get, '/path/', 'request'), 'request')
      end

      test 'use default app if path is not found' do
        router = Fluent::PluginHelper::HttpServer::Router.new
        req = flexmock('request', path: 'path/')
        assert_equal(router.route!(:get, '/path/', req), [404, { 'Content-Type' => 'text/plain' }, "404 Not Found\n"])
      end

      test 'default app is configurable' do
        router = Fluent::PluginHelper::HttpServer::Router.new(->(req) { req })
        assert_equal(router.route!(:get, '/path/', 'hello'), 'hello')
      end
    end
  end
end

Version data entries

93 entries across 93 versions & 7 rubygems

Version Path
fluentd-1.16.7-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.16.7-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.16.7-x64-mingw-ucrt test/plugin_helper/http_server/test_route.rb
fluentd-1.16.7 test/plugin_helper/http_server/test_route.rb
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin_helper/http_server/test_route.rb
fluentd-1.16.6-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.16.6-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.16.6-x64-mingw-ucrt test/plugin_helper/http_server/test_route.rb
fluentd-1.16.6 test/plugin_helper/http_server/test_route.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin_helper/http_server/test_route.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin_helper/http_server/test_route.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/test/plugin_helper/http_server/test_route.rb
fluentd-1.17.0-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.17.0-x64-mingw-ucrt test/plugin_helper/http_server/test_route.rb
fluentd-1.17.0-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.17.0 test/plugin_helper/http_server/test_route.rb
fluentd-1.16.5-x64-mingw-ucrt test/plugin_helper/http_server/test_route.rb
fluentd-1.16.5-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.16.5-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.16.5 test/plugin_helper/http_server/test_route.rb