Sha256: 7b5b21d13e204d458f90fc3ccd5acb799efd921611e1fc0a87e0310f0feaaf51

Contents?: true

Size: 1.81 KB

Versions: 21

Compression:

Stored size: 1.81 KB

Contents

require 'flydata/source_mysql/generate_source_dump'

module Flydata
module SourceMysql

describe GenerateSourceDump do
  let(:subject_object) { described_class.new(source, dp, options) }

  let(:source) { double('source') }
  before do
    allow(source).to receive(:de).and_return(de)
  end
  let(:dp) { double('dp') }
  let(:options) { double('options') }

  let(:de) { {
    "mysql_data_entry_preference" => {
      "host" => "foo",
      "port" => 1234,
      "tables" => all_tables,
    }
  } }

  let(:all_tables) { %w|a b c d| + partial_tables }
  let(:partial_tables) { %w|e f| }
  let(:file_path) { double('file_path') }
  let(:src_pos_callback) { Proc.new{} }
  let(:db_size_check) { double('db_size_check') }
  let(:size) { double('size') }

  let(:options_with_partial_tables) {
    prefs = de['mysql_data_entry_preference'].clone
    prefs["tables"] = partial_tables
    prefs
  }

  describe '#dump_size' do
    subject { subject_object.dump_size(partial_tables) }

    it 'creates SyncDatabaseSizeCheck object with correct parameter' do
      expect(SyncDatabaseSizeCheck).to receive(:new).
        with(options_with_partial_tables).and_return(db_size_check)
      expect(db_size_check).to receive(:get_db_bytesize).and_return(size)

      expect(subject).to eq size
    end
  end

  describe '#dump' do
    subject { subject_object.dump(partial_tables, file_path, &src_pos_callback) }

    let(:dump_generator) { double('dump_generator') }
    before do
      allow(dump_generator).to receive(:dump)
    end

    it 'creates dump_generator with correct parameters' do
      expect(Parser::MysqlDumpGeneratorNoMasterData).to receive(:new).
        with(options_with_partial_tables).and_return(dump_generator)
      expect(dump_generator).to receive(:dump).
        with(file_path, &src_pos_callback)

      subject
    end
  end
end

end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
flydata-0.8.10.2 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.10.1 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.9.11 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.10 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.9 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.8 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.7 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.6 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.5 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.4 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.3 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.2 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.1 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.8.0 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.7.19 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.7.18 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.7.17 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.7.16 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.7.15 spec/flydata/source_mysql/generate_source_dump_spec.rb
flydata-0.7.14 spec/flydata/source_mysql/generate_source_dump_spec.rb