Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Aug 14, 2023
1 parent 3ab75d5 commit 93850d9
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions spec/lib/admin/system_check/elasticsearch_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@

describe 'pass?' do
context 'when chewy is enabled' do
before { allow(Chewy).to receive(:enabled?).and_return(true) }
before do
allow(Chewy).to receive(:enabled?).and_return(true)
allow(Chewy.client.cluster).to receive(:health).and_return({ 'status' => 'green' })
allow(Chewy.client.indices).to receive(:get_mapping).and_return({
AccountsIndex.index_name => AccountsIndex.mappings_hash.deep_stringify_keys,
StatusesIndex.index_name => StatusesIndex.mappings_hash.deep_stringify_keys,
InstancesIndex.index_name => InstancesIndex.mappings_hash.deep_stringify_keys,
TagsIndex.index_name => TagsIndex.mappings_hash.deep_stringify_keys,
})
end

context 'when running version is present and high enough' do
before do
Expand Down Expand Up @@ -67,8 +76,19 @@
end

describe 'message' do
before do
allow(Chewy).to receive(:enabled?).and_return(true)
allow(Chewy.client.cluster).to receive(:health).and_return({ 'status' => 'green' })
allow(Chewy.client.indices).to receive(:get_mapping).and_return({
AccountsIndex.index_name => AccountsIndex.mappings_hash.deep_stringify_keys,
StatusesIndex.index_name => StatusesIndex.mappings_hash.deep_stringify_keys,
InstancesIndex.index_name => InstancesIndex.mappings_hash.deep_stringify_keys,
TagsIndex.index_name => TagsIndex.mappings_hash.deep_stringify_keys,
})
end

context 'when running version is present' do
before { allow(Chewy.client).to receive(:info).and_return({ 'version' => { 'number' => '999.99.9' } }) }
before { allow(Chewy.client).to receive(:info).and_return({ 'version' => { 'number' => '1.2.3' } }) }

it 'sends class name symbol to message instance' do
allow(Admin::SystemCheck::Message).to receive(:new)
Expand All @@ -77,7 +97,7 @@
check.message

expect(Admin::SystemCheck::Message).to have_received(:new)
.with(:elasticsearch_version_check, 'Elasticsearch 999.99.9 is running while 7.x is required')
.with(:elasticsearch_version_check, 'Elasticsearch 1.2.3 is running while 7.x is required')
end
end

Expand Down

0 comments on commit 93850d9

Please sign in to comment.