Sha256: 43a3754c13512d9754383ff443cb57af9df4a715ea372d9093940f758d3b0327

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require_relative 'shared_hosts_context'
require_relative 'different_redis_type_migrator'
require_relative 'pretested_migrator'

describe Redis::NativeMigrator do
  let(:migrator) { Redis::NativeMigrator.new(old_hosts) }
  include_context 'shared hosts context'

  let(:old_cluster) { Redis::Distributed.new(old_hosts) }
  let(:new_cluster) { Redis::Distributed.new(new_hosts) }

  before { allow(migrator).to receive(:redis).and_return(old_cluster) }

  describe '#migrate' do
    context do
      let(:node) { new_cluster.node_for(key) }
      let(:source_node) { old_cluster.node_for(key) }
      let(:destination_cluster) { source_node.client.select(10); source_node }
      before do
        allow_any_instance_of(MockRedis).to receive(:migrate) do |key|
          source_node.move(key, 10)
        end
      end

      it_behaves_like 'different redis type migrator'
    end

    context do
      let(:old_cluster) { Redis::Distributed.new([old_hosts.first]) }
      let(:source_node) { old_cluster.nodes.first }
      let(:destination_cluster) { source_node.client.select(10); source_node }

      before do
        allow_any_instance_of(MockRedis).to receive(:migrate) do |key|
          source_node.move(key, 10)
        end
      end

      it_behaves_like 'pretested migrator'
      # Not supported in Redis < 3.0
      # it_behaves_like 'safe pretested migrator'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis_migrator-0.1.2 spec/redis_native_migrator_spec.rb
redis_migrator-0.1.1 spec/redis_native_migrator_spec.rb