Avoid connecting to a running ES instance in ES search check spec (#26413)
This commit is contained in:
parent
405f141fe0
commit
d9a9323968
1 changed files with 9 additions and 5 deletions
|
@ -49,11 +49,7 @@ describe Admin::SystemCheck::ElasticsearchCheck do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when running version is missing' do
|
context 'when running version is missing' do
|
||||||
before do
|
before { stub_elasticsearch_error }
|
||||||
client = instance_double(Elasticsearch::Transport::Client)
|
|
||||||
allow(client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Error)
|
|
||||||
allow(Chewy).to receive(:client).and_return(client)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns false' do
|
it 'returns false' do
|
||||||
expect(check.pass?).to be false
|
expect(check.pass?).to be false
|
||||||
|
@ -86,6 +82,8 @@ describe Admin::SystemCheck::ElasticsearchCheck do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when running version is missing' do
|
context 'when running version is missing' do
|
||||||
|
before { stub_elasticsearch_error }
|
||||||
|
|
||||||
it 'sends class name symbol to message instance' do
|
it 'sends class name symbol to message instance' do
|
||||||
allow(Admin::SystemCheck::Message).to receive(:new)
|
allow(Admin::SystemCheck::Message).to receive(:new)
|
||||||
.with(:elasticsearch_running_check)
|
.with(:elasticsearch_running_check)
|
||||||
|
@ -97,4 +95,10 @@ describe Admin::SystemCheck::ElasticsearchCheck do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def stub_elasticsearch_error
|
||||||
|
client = instance_double(Elasticsearch::Transport::Client)
|
||||||
|
allow(client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Error)
|
||||||
|
allow(Chewy).to receive(:client).and_return(client)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue