Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reactive_caching_worker_spec.rb « workers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6c74c4ea072c8ea52312eb76e5e6e528245a4790 (plain)
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
# frozen_string_literal: true

require 'spec_helper'

describe ReactiveCachingWorker do
  describe '#perform' do
    context 'when user configured kubernetes from CI/CD > Clusters' do
      let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
      let(:project) { cluster.project }
      let!(:environment) { create(:environment, project: project) }

      it 'calls #exclusively_update_reactive_cache!' do
        expect_any_instance_of(Environment).to receive(:exclusively_update_reactive_cache!)

        described_class.new.perform("Environment", environment.id)
      end

      context 'when ReactiveCaching::ExceededReactiveCacheLimit is raised' do
        it 'avoids failing the job and tracks via Gitlab::ErrorTracking' do
          allow_any_instance_of(Environment).to receive(:exclusively_update_reactive_cache!)
            .and_raise(ReactiveCaching::ExceededReactiveCacheLimit)

          expect(Gitlab::ErrorTracking).to receive(:track_exception)
            .with(kind_of(ReactiveCaching::ExceededReactiveCacheLimit))

          described_class.new.perform("Environment", environment.id)
        end
      end
    end
  end
end