Sha256: b0b4acdf807c2ceac78cb9706ea40b6d361340c17fdc6083ea3f6e72ec234a7b

Contents?: true

Size: 1.02 KB

Versions: 57

Compression:

Stored size: 1.02 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 HtttpHelperRouterTest < 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: #{req.path}\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

57 entries across 57 versions & 1 rubygems

Version Path
fluentd-1.10.1-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.10.1-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.10.1 test/plugin_helper/http_server/test_route.rb
fluentd-1.10.0-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.10.0-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.10.0 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.3-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.3-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.3 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.2-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.2-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.2 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.1-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.1-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.1 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.0-x64-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.0-x86-mingw32 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.0 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.0.rc2 test/plugin_helper/http_server/test_route.rb
fluentd-1.9.0.rc1 test/plugin_helper/http_server/test_route.rb