Sha256: e2e7017f312b4af925a90d197302556e45fbf1701015d2f425d1bfaebb8276fb

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require 'test_helper'

class PtOscMigrationUnitTest < Test::Unit::TestCase
  context 'with a pt-osc migration' do
    setup do
      @migration = ActiveRecord::PtOscMigration.new
    end

    context '#percona_command' do
      context 'connected to a pt-osc database' do
        setup do
          ActiveRecord::Base.establish_connection(test_spec)
          @migration.instance_variable_set(:@connection, ActiveRecord::Base.connection)
        end

        should 'only include flags in DEFAULT_FLAGS' do
          flag = ActiveRecord::PtOscMigration::DEFAULT_FLAGS.first
          begin
            flag = Faker::Lorem.words.join('-')
          end while flag.in? ActiveRecord::PtOscMigration::DEFAULT_FLAGS

          command = @migration.send(:percona_command, '', '', '', flag => nil)
          assert_equal false, command.include?(flag), "Flag #{flag} was given but should not have been."
        end

        should 'perform a dry run if execute not specified' do
          command = @migration.send(:percona_command, '', '', '')
          assert command.include?('--dry-run')
        end

        should 'perform only execute if specified' do
          command = @migration.send(:percona_command, '', '', '', execute: true)
          assert_equal false, command.include?('--dry-run')
          assert command.include?('--execute')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pt-osc-0.0.2 test/unit/pt_osc_migration_unit_test.rb
pt-osc-0.0.1 test/unit/pt_osc_migration_unit_test.rb