diff options
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r-- | spec/models/deployment_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index aad215d5f41..eba0175c54c 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -90,6 +90,35 @@ describe Deployment, models: true do end end + describe '#additional_metrics' do + let(:deployment) { create(:deployment) } + + subject { deployment.additional_metrics } + + context 'metrics are disabled' do + it { is_expected.to eq({}) } + end + + context 'metrics are enabled' do + let(:simple_metrics) do + { + success: true, + metrics: {}, + last_update: 42 + } + end + + let(:prometheus_service) { double('prometheus_service') } + + before do + allow(deployment).to receive(:prometheus_service).and_return(prometheus_service) + allow(prometheus_service).to receive(:additional_deployment_metrics).and_return(simple_metrics) + end + + it { is_expected.to eq(simple_metrics.merge({ deployment_time: deployment.created_at.to_i })) } + end + end + describe '#stop_action' do let(:build) { create(:ci_build) } |