~cytrogen/masto-fe

ref: 88ff45a3b2fba3f119796e5f8946bceea0f88be6 masto-fe/spec/lib/admin/system_check/sidekiq_process_check_spec.rb -rw-r--r-- 1.3 KiB
88ff45a3 — Claire Merge commit 'facfec1ba36cee27f232ebff90b990933719235a' into glitch-soc/merge-upstream 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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