Sha256: 951d1fc9fca87e41a407c578c29341720937c75e0daa03d2fc35f1813efea1e9

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path("../../spec_helper", __FILE__)

describe RedisRing::Node do

  before(:each) do
    @node = RedisRing::Node.new(@slave_rpc = FakeSlaveRPC.new.connection("some_host", 666), "some_host", 666)

    @slave_rpc.status = {
      "joined" => true,
      "running_shards" => [1, 2, 3],
      "available_shards" => { "1" => 1233, "2" => 4566 }
    }
  end

  it "should return some sane defults when calling without update_status!" do
    @node.joined?.should be_false
    @node.running_shards.should == []
    @node.available_shards.should == {}
  end

  it "should only update the data when update_status! is called" do
    @node.update_status!

    @node.joined?.should be_true
    @node.running_shards.should == [1, 2, 3]
    @node.available_shards.should == {1 => 1233, 2 => 4566}
  end

  it "should reflect start_shard in running shards without calling update_status!" do
    @node.start_shard(9)

    @node.running_shards.should == [9]
  end

  it "should send rpc to slave on start_shard" do
    @node.start_shard(9)

    @slave_rpc.started_shards.should == [9]
  end

  it "should reflect stop_shard in running shards without calling update_status!" do
    @node.update_status!
    @node.stop_shard(3)

    @node.running_shards.should == [1, 2]
  end

  it "should send rpc to slave on start_shard" do
    @node.stop_shard(9)

    @slave_rpc.stopped_shards.should == [9]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redis_ring-0.1.3 spec/redis_ring/node_spec.rb
redis_ring-0.1.2 spec/redis_ring/node_spec.rb
redis_ring-0.1.1 spec/redis_ring/node_spec.rb
redis_ring-0.1.0 spec/redis_ring/node_spec.rb