2020-02-08 01:08:50 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Ci::PipelineBridgeStatusService do
|
|
|
|
let(:user) { build(:user) }
|
|
|
|
let(:project) { build(:project) }
|
|
|
|
let(:pipeline) { build(:ci_pipeline, project: project) }
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
subject { described_class.new(project, user).execute(pipeline) }
|
|
|
|
|
|
|
|
context 'when pipeline has upstream bridge' do
|
|
|
|
let(:bridge) { build(:ci_bridge) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
pipeline.source_bridge = bridge
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'calls inherit_status_from_downstream on upstream bridge' do
|
|
|
|
expect(bridge).to receive(:inherit_status_from_downstream!).with(pipeline)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
2020-03-12 05:09:55 -04:00
|
|
|
|
|
|
|
context 'when bridge job status raises state machine errors' do
|
|
|
|
before do
|
|
|
|
pipeline.drop!
|
|
|
|
bridge.drop!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'tracks the exception' do
|
|
|
|
expect(Gitlab::ErrorTracking)
|
|
|
|
.to receive(:track_exception)
|
|
|
|
.with(
|
|
|
|
instance_of(Ci::Bridge::InvalidTransitionError),
|
|
|
|
bridge_id: bridge.id,
|
|
|
|
downstream_pipeline_id: pipeline.id)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
2020-02-08 01:08:50 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|