diff options
Diffstat (limited to 'spec/lib/admin/system_check/sidekiq_process_check_spec.rb')
-rw-r--r-- | spec/lib/admin/system_check/sidekiq_process_check_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/lib/admin/system_check/sidekiq_process_check_spec.rb b/spec/lib/admin/system_check/sidekiq_process_check_spec.rb new file mode 100644 index 000000000..9bd9daddf --- /dev/null +++ b/spec/lib/admin/system_check/sidekiq_process_check_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Admin::SystemCheck::SidekiqProcessCheck do + subject(:check) { described_class.new(user) } + + let(:user) { Fabricate(:user) } + + it_behaves_like 'a check available to devops users' + + describe 'pass?' do + context 'when missing queues is empty' do + before do + process_set = instance_double(Sidekiq::ProcessSet, reduce: []) + allow(Sidekiq::ProcessSet).to receive(:new).and_return(process_set) + end + + it 'returns true' do + expect(check.pass?).to be true + end + end + + context 'when missing queues is not empty' do + before do + process_set = instance_double(Sidekiq::ProcessSet, reduce: [:something]) + allow(Sidekiq::ProcessSet).to receive(:new).and_return(process_set) + end + + it 'returns false' do + expect(check.pass?).to be false + end + end + end + + describe 'message' do + it 'sends values to message instance' do + allow(Admin::SystemCheck::Message).to receive(:new).with(:sidekiq_process_check, 'default, push, mailers, pull, scheduler, ingress') + + check.message + + expect(Admin::SystemCheck::Message).to have_received(:new).with(:sidekiq_process_check, 'default, push, mailers, pull, scheduler, ingress') + end + end +end |