Skip to content

Commit

Permalink
Added UTs
Browse files Browse the repository at this point in the history
Signed-off-by: Athishpranav2003 <[email protected]>
  • Loading branch information
Athishpranav2003 committed Aug 1, 2024
1 parent 29d0dca commit 08389fd
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions spec/fluent/plugin/in_prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@
expect(driver.instance.metrics_path).to eq('/_test')
end
end

describe 'content_encoding_identity' do
let(:config) { CONFIG + %[
content_encoding identity
] }
it 'should be configurable' do
expect(driver.instance.content_encoding).to eq(:identity)
end
end

describe 'content_encoding_gzip' do
let(:config) { CONFIG + %[
content_encoding gzip
] }
it 'should be configurable' do
expect(driver.instance.content_encoding).to eq(:gzip)
end
end
end

describe '#start' do
Expand Down Expand Up @@ -197,6 +215,40 @@
end
end
end

context 'response content_encoding identity' do
let(:config) { LOCAL_CONFIG + %[
content_encoding identity
] }
it 'exposes metric' do
driver.run(timeout: 1) do
registry = driver.instance.instance_variable_get(:@registry)
registry.counter(:test,docstring: "Testing metrics") unless registry.exist?(:test)
Net::HTTP.start("127.0.0.1", port) do |http|
req = Net::HTTP::Get.new("/metrics")
res = http.request(req)
expect(res.body).to include("test Testing metrics")
end
end
end
end

context 'response content_encoding gzip' do
let(:config) { LOCAL_CONFIG + %[
content_encoding gzip
] }
it 'exposes metric' do
driver.run(timeout: 1) do
registry = driver.instance.instance_variable_get(:@registry)
registry.counter(:test,docstring: "Testing metrics") unless registry.exist?(:test)
Net::HTTP.start("127.0.0.1", port) do |http|
req = Net::HTTP::Get.new("/metrics")
res = http.request(req)
expect(res.body).to include("test Testing metrics")
end
end
end
end
end

describe '#run_multi_workers' do
Expand Down

0 comments on commit 08389fd

Please sign in to comment.