spec/outputs/charrington_spec.rb in logstash-output-charrington-0.3.14 vs spec/outputs/charrington_spec.rb in logstash-output-charrington-0.3.15
- old
+ new
@@ -2,16 +2,19 @@
describe LogStash::Outputs::Charrington do
include_context 'postgres'
include_context 'pipeline'
- describe 'a new payload with one event' do
+ describe 'a new payload with one event that truncates strings correctly' do
+ let(:too_big) do
+ "0123456789" * 30
+ end
let(:config) do
<<-CONFIG
input {
generator {
- message => '{"app_name": "Web App", "event": "schemaless", "meta": { "type": "XML" }, "published_at": "2019-07-29T20:09:18Z" }'
+ message => '{"app_name": "Web App", "event": "schemaless", "meta": { "type": "XML", "too_big": "#{too_big}" }, "published_at": "2019-07-29T20:09:18Z" }'
codec => 'json'
count => 1
}
}
@@ -29,11 +32,11 @@
it 'creates a table and inserts a record' do
drop_table('tracks')
create_tracks_table
drop_table('schemaless')
run_pipeline
- expect(query('SELECT * FROM schemaless')).to match_array([{id: "1", app_name: "Web App", event: "schemaless", inserted_at: a_kind_of(String), :meta_type => "XML", :published_at => "2019-07-29 20:09:18"}])
+ expect(query('SELECT * FROM schemaless')).to match_array([{id: "1", app_name: "Web App", event: "schemaless", inserted_at: a_kind_of(String), :meta_type => "XML", :meta_too_big => too_big[0,254], :published_at => "2019-07-29 20:09:18"}])
expect(query('SELECT COUNT(1) FROM schemaless').first[:count]).to eq("1")
end
end
describe 'removes a trailing plus sign' do
@@ -169,11 +172,11 @@
CONFIG
end
it 'creates a table and inserts the first record and alters the table for the second record' do
drop_table('tracks')
- create_tracks_table('dea_test')
create("CREATE SCHEMA IF NOT EXISTS #{schema}")
+ create_tracks_table('dea_test')
drop_table("#{schema}.from_agent")
run_pipeline
expect(query("SELECT * FROM #{schema}.from_agent")).to match_array([
{app_name: 'Web App', event: 'From Agent', id: '1', inserted_at: a_kind_of(String), meta_file_name: nil, meta_type: 'XML'},
{app_name: 'Web App', event: 'From Agent', id: '2', inserted_at: a_kind_of(String), meta_file_name: 'virus.pdf', meta_type: 'XML'}