correct flaky spec
This commit is contained in:
parent
d7a2584c6e
commit
e8cdb1d8a7
|
@ -102,20 +102,6 @@ describe DiscourseRedis do
|
|||
expect(connector.resolve).to eq(config)
|
||||
end
|
||||
|
||||
it 'should return the slave config when master is down' do
|
||||
begin
|
||||
Redis::Client.any_instance.expects(:call).raises(Redis::CannotConnectError).once
|
||||
expect { connector.resolve }.to raise_error(Redis::CannotConnectError)
|
||||
|
||||
config = connector.resolve
|
||||
|
||||
expect(config[:host]).to eq(slave_host)
|
||||
expect(config[:port]).to eq(slave_port)
|
||||
ensure
|
||||
fallback_handler.master = true
|
||||
end
|
||||
end
|
||||
|
||||
class BrokenRedis
|
||||
def initialize(error)
|
||||
@error = error
|
||||
|
@ -129,6 +115,20 @@ describe DiscourseRedis do
|
|||
end
|
||||
end
|
||||
|
||||
it 'should return the slave config when master is down' do
|
||||
begin
|
||||
error = Redis::CannotConnectError
|
||||
expect { connector.resolve(BrokenRedis.new(error)) }.to raise_error(Redis::CannotConnectError)
|
||||
|
||||
config = connector.resolve
|
||||
|
||||
expect(config[:host]).to eq(slave_host)
|
||||
expect(config[:port]).to eq(slave_port)
|
||||
ensure
|
||||
fallback_handler.master = true
|
||||
end
|
||||
end
|
||||
|
||||
it "should return the slave config when master's hostname cannot be resolved" do
|
||||
begin
|
||||
error = RuntimeError.new('Name or service not known')
|
||||
|
|
Loading…
Reference in New Issue