spec/fluent/plugin/prometheus_spec.rb in fluent-plugin-prometheus-0.5.0 vs spec/fluent/plugin/prometheus_spec.rb in fluent-plugin-prometheus-1.0.0

- old
+ new

@@ -1,11 +1,12 @@ require 'spec_helper' require 'fluent/plugin/in_prometheus' +require 'fluent/test/driver/input' require 'net/http' -describe Fluent::PrometheusInput do +describe Fluent::Plugin::PrometheusInput do CONFIG = %[ type prometheus ] LOCAL_CONFIG = %[ @@ -13,11 +14,11 @@ bind 127.0.0.1 ] let(:config) { CONFIG } let(:port) { 24231 } - let(:driver) { Fluent::Test::InputTestDriver.new(Fluent::PrometheusInput).configure(config) } + let(:driver) { Fluent::Test::Driver::Input.new(Fluent::Plugin::PrometheusInput).configure(config) } describe '#configure' do describe 'bind' do let(:config) { CONFIG + %[ bind 127.0.0.1 @@ -48,11 +49,11 @@ describe '#run' do context '/metrics' do let(:config) { LOCAL_CONFIG } it 'returns 200' do - driver.run do + driver.run(timeout: 1) do Net::HTTP.start("127.0.0.1", port) do |http| req = Net::HTTP::Get.new("/metrics") res = http.request(req) expect(res.code).to eq('200') end @@ -61,10 +62,10 @@ end context '/foo' do let(:config) { LOCAL_CONFIG } it 'does not return 200' do - driver.run do + driver.run(timeout: 1) do Net::HTTP.start("127.0.0.1", port) do |http| req = Net::HTTP::Get.new("/foo") res = http.request(req) expect(res.code).not_to eq('200') end