spec/outputs/charrington_spec.rb in logstash-output-charrington-0.3.12 vs spec/outputs/charrington_spec.rb in logstash-output-charrington-0.3.13

- old
+ new

@@ -18,10 +18,11 @@ output { charrington { connection_string => '#{@url}' driver_jar_path => '#{driver_path}' schema => '' + transformer => 'postgres' } } CONFIG end @@ -47,10 +48,11 @@ output { charrington { connection_string => '#{@url}' driver_jar_path => '#{driver_path}' schema => '' + transformer => 'postgres' } } CONFIG end @@ -79,10 +81,11 @@ output { charrington { connection_string => '#{@url}' driver_jar_path => '#{driver_path}' schema => '' + transformer => 'postgres' } } CONFIG end @@ -111,10 +114,11 @@ output { charrington { connection_string => '#{@url}' driver_jar_path => '#{driver_path}' schema => '' + transformer => 'postgres' } } CONFIG end @@ -151,10 +155,11 @@ output { charrington { connection_string => '#{@url}' driver_jar_path => '#{driver_path}' schema => '#{schema}' + transformer => 'postgres' } } CONFIG end @@ -184,19 +189,52 @@ output { charrington { connection_string => '#{@url}' driver_jar_path => '#{driver_path}' schema => '' + transformer => 'postgres' } } CONFIG end it 'creates a table and inserts a record' do drop_table('camel_case_this') run_pipeline expect(query('SELECT * FROM camel_case_this')).to match_array([{id: "1", app_name: "Web App", event: "camelCase this", inserted_at: a_kind_of(String), :meta_type => "XML"}]) expect(query('SELECT COUNT(1) FROM camel_case_this').first[:count]).to eq("1") + end + end + + describe 'a new payload with one event transformed to be redshift shape' do + let(:config) do + <<-CONFIG + input { + generator { + message => '{"app_name": "Web App", "event": "schemaless", "meta": { "type": "XML" }, "published_at": "2019-07-29T20:09:18Z" }' + codec => 'json' + count => 1 + } + } + + output { + charrington { + connection_string => '#{@url}' + driver_jar_path => '#{driver_path}' + schema => '' + transformer => 'redshift' + } + } + CONFIG + end + + it 'creates a table and inserts a record with data the shape of redshift' do + drop_table('schemaless') + run_pipeline + expect(query('SELECT * FROM schemaless')).to match_array([ + {:anonymous_id=>"", :app_name=>"Web App", :event=>"schemaless", :event_text=>"schemaless", :id=>a_kind_of(String), :original_timestamp=>a_kind_of(String), :received_at=>a_kind_of(String), :sent_at=>"2019-07-29 20:09:18", :timestamp=>a_kind_of(String), :type=>"XML", :uuid_ts=>a_kind_of(String)} + ]) + expect(query('SELECT COUNT(1) FROM schemaless').first[:count]).to eq("1") end end end