From 90fef189c21be9db445390d7af528968493b1f0a Mon Sep 17 00:00:00 2001 From: Nick Carboni Date: Tue, 21 Jan 2020 17:07:14 -0500 Subject: [PATCH] Don't return [nil] when we don't have a local server yet --- lib/workers/evm_server.rb | 2 +- spec/lib/workers/evm_server_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/workers/evm_server.rb b/lib/workers/evm_server.rb index 8a6303b53f9c..2d0b71ba49b6 100644 --- a/lib/workers/evm_server.rb +++ b/lib/workers/evm_server.rb @@ -92,7 +92,7 @@ def monitoring_server?(server) end def servers_from_db - MiqEnvironment::Command.is_podified? ? MiqServer.in_my_region.to_a : [MiqServer.my_server(true)] + MiqEnvironment::Command.is_podified? ? MiqServer.in_my_region.to_a : [MiqServer.my_server(true)].compact end def set_process_title diff --git a/spec/lib/workers/evm_server_spec.rb b/spec/lib/workers/evm_server_spec.rb index 3d46ad5418bf..c728bd3b6d40 100644 --- a/spec/lib/workers/evm_server_spec.rb +++ b/spec/lib/workers/evm_server_spec.rb @@ -10,6 +10,10 @@ expect(servers_to_monitor.first.id).to eq(server.id) end + it "doesn't give a nil server when there is no local server" do + expect(subject.servers_to_monitor).to be_empty + end + context "when podified" do let(:expected_ids) { MiqServer.pluck(:id) }