require 'timecop' require 'fileutils' require 'flydata/fluent-plugins/flydata_plugin_ext/flydata_sync_context' module Fluent # plugin and config is required shared_examples 'flydata sync shared examples' do include_context 'flydata sync context' describe '#configure' do let(:config) do c = default_config c = replace_conf(c, 'tables', 'table_1,table_2') c = replace_conf(c, 'tables_append_only', 'table_3,table_4') c end subject { Test.configure_plugin(plugin, config) } before do create_table_pos_file(%w(table_1 table_2 table_3)) create_table_rev_file('table_1', '2') subject end it { expect(config_value(:@data_entry_name)).to be_kind_of(String) } it { expect(config_value(:@data_entry_type)).to be_kind_of(String) } it { expect(config_value(:@tag)).to be_kind_of(String) } it { expect(config_value(:@position_file)).to be_kind_of(String) } it 'sets @source_position_file' do expect(config_value(:@source_position_file)). to be_kind_of(described_class::SOURCE_POSITION_FILE_CLASS) end it 'sets @sent_position_file' do expect(config_value(:@sent_position_file)). to be_kind_of(described_class::SOURCE_POSITION_FILE_CLASS) end it { expect(config_value(:@data_entry)).to have_key('name') } it { expect(config_value(:@data_entry)).to have_key('type') } it { expect(config_value(:@tables)).to be_kind_of(Array) } it do expect(config_value(:@tables)).to eq(%w(table_1 table_2 table_3)) end it do expect(config_value(:@omit_events)).to eq( 'table_3' => [:delete, :truncate_table], 'table_4' => [:delete, :truncate_table], ) end it do expect(config_value(:@table_revs)).to eq( 'table_1' => 2, 'table_2' => 1, 'table_3' => 1, ) end end end end