Sha256: 81dccdf2f630d7986b54b97e9ac8485dc75394007446c0b2f2766e9ba41f9634

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 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
        }
      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

5 entries across 5 versions & 1 rubygems

Version Path
flydata-0.3.16 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.15 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.14 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.13 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
flydata-0.3.12 spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb