2019-03-30 03:15:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-16 23:09:50 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ReactiveCachingWorker do
|
|
|
|
describe '#perform' do
|
2017-11-27 07:48:54 -05:00
|
|
|
context 'when user configured kubernetes from CI/CD > Clusters' do
|
|
|
|
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
|
|
|
|
let(:project) { cluster.project }
|
2019-05-22 14:55:15 -04:00
|
|
|
let!(:environment) { create(:environment, project: project) }
|
2017-11-27 07:48:54 -05:00
|
|
|
|
2017-11-27 09:55:25 -05:00
|
|
|
it 'calls #exclusively_update_reactive_cache!' do
|
2019-05-22 14:55:15 -04:00
|
|
|
expect_any_instance_of(Environment).to receive(:exclusively_update_reactive_cache!)
|
2017-11-27 09:55:25 -05:00
|
|
|
|
2019-05-22 14:55:15 -04:00
|
|
|
described_class.new.perform("Environment", environment.id)
|
2017-11-27 09:55:25 -05:00
|
|
|
end
|
2020-02-10 10:08:54 -05:00
|
|
|
|
|
|
|
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
|
2016-12-16 23:09:50 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|