Commit 03848e84 authored by Sean Arnold's avatar Sean Arnold

Update ambiguous alert var name in specs

- Update and rename appropriately
parent 1b711e20
...@@ -5,9 +5,9 @@ require 'spec_helper' ...@@ -5,9 +5,9 @@ require 'spec_helper'
RSpec.describe AlertManagement::AlertsFinder, '#execute' do RSpec.describe AlertManagement::AlertsFinder, '#execute' do
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:alert_1) { create(:alert_management_alert, :all_fields, :resolved, project: project, ended_at: 1.year.ago, events: 2, severity: :high) } let_it_be(:resolved_alert) { create(:alert_management_alert, :all_fields, :resolved, project: project, ended_at: 1.year.ago, events: 2, severity: :high) }
let_it_be(:alert_2) { create(:alert_management_alert, :all_fields, :ignored, project: project, events: 1, severity: :critical) } let_it_be(:ignored_alert) { create(:alert_management_alert, :all_fields, :ignored, project: project, events: 1, severity: :critical) }
let_it_be(:alert_3) { create(:alert_management_alert, :all_fields) } let_it_be(:triggered_alert) { create(:alert_management_alert, :all_fields) }
let(:params) { {} } let(:params) { {} }
describe '#execute' do describe '#execute' do
...@@ -23,13 +23,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -23,13 +23,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
end end
context 'empty params' do context 'empty params' do
it { is_expected.to contain_exactly(alert_1, alert_2) } it { is_expected.to contain_exactly(resolved_alert, ignored_alert) }
end end
context 'iid given' do context 'iid given' do
let(:params) { { iid: alert_1.iid } } let(:params) { { iid: resolved_alert.iid } }
it { is_expected.to match_array(alert_1) } it { is_expected.to match_array(resolved_alert) }
context 'unknown iid' do context 'unknown iid' do
let(:params) { { iid: 'unknown' } } let(:params) { { iid: 'unknown' } }
...@@ -41,13 +41,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -41,13 +41,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
context 'status given' do context 'status given' do
let(:params) { { status: AlertManagement::Alert::STATUSES[:resolved] } } let(:params) { { status: AlertManagement::Alert::STATUSES[:resolved] } }
it { is_expected.to match_array(alert_1) } it { is_expected.to match_array(resolved_alert) }
context 'with an array of statuses' do context 'with an array of statuses' do
let(:alert_3) { create(:alert_management_alert) } let(:triggered_alert) { create(:alert_management_alert) }
let(:params) { { status: [AlertManagement::Alert::STATUSES[:resolved]] } } let(:params) { { status: [AlertManagement::Alert::STATUSES[:resolved]] } }
it { is_expected.to match_array(alert_1) } it { is_expected.to match_array(resolved_alert) }
end end
context 'with no alerts of status' do context 'with no alerts of status' do
...@@ -59,13 +59,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -59,13 +59,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
context 'with an empty status array' do context 'with an empty status array' do
let(:params) { { status: [] } } let(:params) { { status: [] } }
it { is_expected.to match_array([alert_1, alert_2]) } it { is_expected.to match_array([resolved_alert, ignored_alert]) }
end end
context 'with an nil status' do context 'with an nil status' do
let(:params) { { status: nil } } let(:params) { { status: nil } }
it { is_expected.to match_array([alert_1, alert_2]) } it { is_expected.to match_array([resolved_alert, ignored_alert]) }
end end
end end
...@@ -74,13 +74,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -74,13 +74,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
context 'sorts alerts ascending' do context 'sorts alerts ascending' do
let(:params) { { sort: 'created_asc' } } let(:params) { { sort: 'created_asc' } }
it { is_expected.to eq [alert_1, alert_2] } it { is_expected.to eq [resolved_alert, ignored_alert] }
end end
context 'sorts alerts descending' do context 'sorts alerts descending' do
let(:params) { { sort: 'created_desc' } } let(:params) { { sort: 'created_desc' } }
it { is_expected.to eq [alert_2, alert_1] } it { is_expected.to eq [ignored_alert, resolved_alert] }
end end
end end
...@@ -88,13 +88,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -88,13 +88,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
context 'sorts alerts ascending' do context 'sorts alerts ascending' do
let(:params) { { sort: 'updated_asc' } } let(:params) { { sort: 'updated_asc' } }
it { is_expected.to eq [alert_1, alert_2] } it { is_expected.to eq [resolved_alert, ignored_alert] }
end end
context 'sorts alerts descending' do context 'sorts alerts descending' do
let(:params) { { sort: 'updated_desc' } } let(:params) { { sort: 'updated_desc' } }
it { is_expected.to eq [alert_2, alert_1] } it { is_expected.to eq [ignored_alert, resolved_alert] }
end end
end end
...@@ -102,13 +102,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -102,13 +102,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
context 'sorts alerts ascending' do context 'sorts alerts ascending' do
let(:params) { { sort: 'started_at_asc' } } let(:params) { { sort: 'started_at_asc' } }
it { is_expected.to eq [alert_1, alert_2] } it { is_expected.to eq [resolved_alert, ignored_alert] }
end end
context 'sorts alerts descending' do context 'sorts alerts descending' do
let(:params) { { sort: 'started_at_desc' } } let(:params) { { sort: 'started_at_desc' } }
it { is_expected.to eq [alert_2, alert_1] } it { is_expected.to eq [ignored_alert, resolved_alert] }
end end
end end
...@@ -116,13 +116,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -116,13 +116,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
context 'sorts alerts ascending' do context 'sorts alerts ascending' do
let(:params) { { sort: 'ended_at_asc' } } let(:params) { { sort: 'ended_at_asc' } }
it { is_expected.to eq [alert_1, alert_2] } it { is_expected.to eq [resolved_alert, ignored_alert] }
end end
context 'sorts alerts descending' do context 'sorts alerts descending' do
let(:params) { { sort: 'ended_at_desc' } } let(:params) { { sort: 'ended_at_desc' } }
it { is_expected.to eq [alert_2, alert_1] } it { is_expected.to eq [ignored_alert, resolved_alert] }
end end
end end
...@@ -133,13 +133,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do ...@@ -133,13 +133,13 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do
context 'sorts alerts ascending' do context 'sorts alerts ascending' do
let(:params) { { sort: 'event_count_asc' } } let(:params) { { sort: 'event_count_asc' } }
it { is_expected.to eq [alert_2, alert_1, alert_count_3, alert_count_6] } it { is_expected.to eq [ignored_alert, resolved_alert, alert_count_3, alert_count_6] }
end end
context 'sorts alerts descending' do context 'sorts alerts descending' do
let(:params) { { sort: 'event_count_desc' } } let(:params) { { sort: 'event_count_desc' } }
it { is_expected.to eq [alert_count_6, alert_count_3, alert_1, alert_2] } it { is_expected.to eq [alert_count_6, alert_count_3, resolved_alert, ignored_alert] }
end end
end end
......
...@@ -7,8 +7,8 @@ RSpec.describe Resolvers::AlertManagement::AlertResolver do ...@@ -7,8 +7,8 @@ RSpec.describe Resolvers::AlertManagement::AlertResolver do
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:alert_1) { create(:alert_management_alert, :resolved, project: project, ended_at: 1.year.ago, events: 2, severity: :high) } let_it_be(:resolved_alert) { create(:alert_management_alert, :resolved, project: project, ended_at: 1.year.ago, events: 2, severity: :high) }
let_it_be(:alert_2) { create(:alert_management_alert, :ignored, project: project, events: 1, severity: :critical) } let_it_be(:ignored_alert) { create(:alert_management_alert, :ignored, project: project, events: 1, severity: :critical) }
let_it_be(:alert_other_proj) { create(:alert_management_alert) } let_it_be(:alert_other_proj) { create(:alert_management_alert) }
let(:args) { {} } let(:args) { {} }
...@@ -24,18 +24,18 @@ RSpec.describe Resolvers::AlertManagement::AlertResolver do ...@@ -24,18 +24,18 @@ RSpec.describe Resolvers::AlertManagement::AlertResolver do
project.add_developer(current_user) project.add_developer(current_user)
end end
it { is_expected.to contain_exactly(alert_1, alert_2) } it { is_expected.to contain_exactly(resolved_alert, ignored_alert) }
context 'finding by iid' do context 'finding by iid' do
let(:args) { { iid: alert_1.iid } } let(:args) { { iid: resolved_alert.iid } }
it { is_expected.to contain_exactly(alert_1) } it { is_expected.to contain_exactly(resolved_alert) }
end end
context 'finding by status' do context 'finding by status' do
let(:args) { { status: [Types::AlertManagement::StatusEnum.values['IGNORED'].value] } } let(:args) { { status: [Types::AlertManagement::StatusEnum.values['IGNORED'].value] } }
it { is_expected.to contain_exactly(alert_2) } it { is_expected.to contain_exactly(ignored_alert) }
end end
describe 'sorting' do describe 'sorting' do
...@@ -45,11 +45,11 @@ RSpec.describe Resolvers::AlertManagement::AlertResolver do ...@@ -45,11 +45,11 @@ RSpec.describe Resolvers::AlertManagement::AlertResolver do
let_it_be(:alert_count_3) { create(:alert_management_alert, project: project, events: 3) } let_it_be(:alert_count_3) { create(:alert_management_alert, project: project, events: 3) }
it 'sorts alerts ascending' do it 'sorts alerts ascending' do
expect(resolve_alerts(sort: :event_count_asc)).to eq [alert_2, alert_1, alert_count_3, alert_count_6] expect(resolve_alerts(sort: :event_count_asc)).to eq [ignored_alert, resolved_alert, alert_count_3, alert_count_6]
end end
it 'sorts alerts descending' do it 'sorts alerts descending' do
expect(resolve_alerts(sort: :event_count_desc)).to eq [alert_count_6, alert_count_3, alert_1, alert_2] expect(resolve_alerts(sort: :event_count_desc)).to eq [alert_count_6, alert_count_3, resolved_alert, ignored_alert]
end end
end end
end end
......
...@@ -249,15 +249,15 @@ RSpec.describe AlertManagement::Alert do ...@@ -249,15 +249,15 @@ RSpec.describe AlertManagement::Alert do
subject { described_class.last_prometheus_alert_by_project_id } subject { described_class.last_prometheus_alert_by_project_id }
let(:project_1) { create(:project) } let(:project_1) { create(:project) }
let!(:alert_1) { create(:alert_management_alert, project: project_1) } let!(:p1_alert_1) { create(:alert_management_alert, project: project_1) }
let!(:alert_2) { create(:alert_management_alert, project: project_1) } let!(:p1_alert_2) { create(:alert_management_alert, project: project_1) }
let(:project_2) { create(:project) } let(:project_2) { create(:project) }
let!(:alert_3) { create(:alert_management_alert, project: project_2) } let!(:p2_alert_1) { create(:alert_management_alert, project: project_2) }
let!(:alert_4) { create(:alert_management_alert, project: project_2) } let!(:p2_alert_2) { create(:alert_management_alert, project: project_2) }
it 'returns the latest alert for each project' do it 'returns the latest alert for each project' do
expect(subject).to contain_exactly(alert_2, alert_4) expect(subject).to contain_exactly(p1_alert_2, p2_alert_2)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment