Sha256: 43d77ad2239f9fa76bf1431dede00e9c69e5c2cf7a89b73d0729daed76df4ce8

Contents?: true

Size: 1.93 KB

Versions: 5

Compression:

Stored size: 1.93 KB

Contents

module Mysql
  shared_context "query handler context" do
    let(:database) { "testdb" }
    let(:table) { "foo" }
    let(:seq) { 200 }
    let(:sync_fm) do
      r = double('sync_fm')
      allow(r).to receive(:get_table_binlog_pos).and_return("mysql-bin.000065\t120")
      allow(r).to receive(:increment_and_save_table_position).with(table).and_yield(seq).and_return(nil)
      allow(r).to receive(:delete_table_binlog_pos).with(table)
      r
    end
    let(:table_meta) { double'table_meta' }
    let(:current_binlog_file) { "mysql-bin.000066" }
    let(:tag) { "some_tag" }
    let(:table_rev) { 1 }
    let(:context) do
      r = double('context')
      allow(r).to receive(:sync_fm).and_return(sync_fm)
      allow(r).to receive(:database).and_return(database)
      allow(r).to receive(:tables).and_return([table])
      allow(r).to receive(:table_meta).and_return(table_meta)
      allow(r).to receive(:current_binlog_file).and_return(current_binlog_file)
      allow(r).to receive(:omit_events).and_return({})
      allow(r).to receive(:table_revs).and_return({ table => table_rev})
      allow(r).to receive(:tag).and_return(tag)
      r
    end
    let(:query) { "a_query" }
    let(:normalized_query) { double('normalized_query') }
    let(:event_length) { 20 }
    let(:next_position) { 200 }
    let(:timestamp) { 1427973738 }
    let(:record) do
      r = double('record')
      allow(r).to receive(:[]).with("db_name").and_return(database)
      allow(r).to receive(:[]).with("query").and_return(query)
      allow(r).to receive(:[]).with("table_name").and_return(table)
      allow(r).to receive(:[]).with("normalized_query").and_return(normalized_query)
      allow(r).to receive(:[]).with("next_position").and_return(next_position)
      allow(r).to receive(:[]).with("event_length").and_return(event_length)
      allow(r).to receive(:[]).with("timestamp").and_return("#{timestamp}")
      r
    end
    subject { described_class.new(context) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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