Sha256: b26b6de267a0e567e71a3513340262155abc20c2c0b17f212158c22837449d14

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

require 'fluent_plugins_spec_helper'
require 'flydata/fluent-plugins/mysql/truncate_table_query_handler'
require 'flydata/fluent-plugins/mysql/shared_query_handler_context'

module Mysql
  describe TruncateTableQueryHandler do
    include_context "query handler context"

    describe '#process' do
      let(:truncate_query) { "TRUNCATE TABLE foo" }
      let(:expected_record) do
        {
          table_name: table,
          query: truncate_query,
          type: :truncate_table,
          respect_order: true,
          src_pos: "#{current_binlog_file}\t#{next_position - event_length}",
          table_rev: table_rev,
          seq: seq,
          v: flydata_record_version
        }
      end
      before do
        allow(record).to receive(:[]).with("query").and_return(truncate_query)
        allow(record).to receive(:[]).with("normalized_query").and_return(truncate_query)
      end
      context "for a non append only table" do
        it "should call Fluent's emit with appropriate params" do
          expect(Fluent::Engine).to receive(:emit).with(tag, timestamp, expected_record)
          expect(subject.process(record))
        end
      end
      context "for an append only table" do
        before do
          allow(context).to receive(:omit_events).and_return({ table => [:delete, :truncate_table] })
        end
        it "should not call Fluent's emit" do
          expect(Fluent::Engine).to receive(:emit).never
          expect(subject.process(record))
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flydata-0.4.1 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.4.0 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.24 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.23 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.22 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.21 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.20 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.19 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.18 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.17 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb