spec/logstash/outputs/scalyr_spec.rb in logstash-output-scalyr-0.1.25.beta vs spec/logstash/outputs/scalyr_spec.rb in logstash-output-scalyr-0.1.26.beta

- old
+ new

@@ -58,10 +58,11 @@ 'api_write_token' => '1234', 'serverhost_field' => 'source_host', 'log_constants' => ['tags'], 'flatten_nested_values' => true, }) + plugin.register mock_client_session = MockClientSession.new it "returns correct stats on get_stats" do stats = mock_client_session.get_stats @@ -73,10 +74,11 @@ 'api_write_token' => '1234', 'serverhost_field' => 'source_host', 'log_constants' => ['tags'], 'flatten_nested_values' => false, }) + plugin1.register() mock_client_session = MockClientSession.new plugin1.instance_variable_set(:@last_status_transmit_time, 100) plugin1.instance_variable_set(:@client_session, mock_client_session) plugin1.instance_variable_set(:@session_id, "some_session_id") plugin1.instance_variable_set(:@plugin_metrics, { @@ -578,9 +580,61 @@ allow(plugin.instance_variable_get(:@logger)).to receive(:error) result = plugin.build_multi_event_request_array([e]) body = JSON.parse(result[0][:body]) expect(body['events'].size).to eq(1) expect(plugin.instance_variable_get(:@logger)).to_not receive(:error) + end + end + + context "when using custom json library" do + it "stdlib (implicit)" do + config = { + 'api_write_token' => '1234', + } + plugin = LogStash::Outputs::Scalyr.new(config) + + allow(plugin).to receive(:send_status).and_return(nil) + plugin.register + e = LogStash::Event.new + e.set('bignumber', 20) + result = plugin.build_multi_event_request_array([e]) + body = JSON.parse(result[0][:body]) + expect(result[0][:body]).to include('{"monitor":"pluginLogstash"}') + expect(body['events'].size).to eq(1) + end + + it "stdlib (explicit)" do + config = { + 'api_write_token' => '1234', + 'json_library' => 'stdlib' + } + plugin = LogStash::Outputs::Scalyr.new(config) + + allow(plugin).to receive(:send_status).and_return(nil) + plugin.register + e = LogStash::Event.new + e.set('bignumber', 20) + result = plugin.build_multi_event_request_array([e]) + body = JSON.parse(result[0][:body]) + expect(result[0][:body]).to include('{"monitor":"pluginLogstash"}') + expect(body['events'].size).to eq(1) + end + + it "jrjackson" do + config = { + 'api_write_token' => '1234', + 'json_library' => 'jrjackson' + } + plugin = LogStash::Outputs::Scalyr.new(config) + + allow(plugin).to receive(:send_status).and_return(nil) + plugin.register + e = LogStash::Event.new + e.set('bignumber', 20) + result = plugin.build_multi_event_request_array([e]) + body = JSON.parse(result[0][:body]) + expect(result[0][:body]).to include('{"monitor":"pluginLogstash"}') + expect(body['events'].size).to eq(1) end end end end