Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
03848e84
Commit
03848e84
authored
Jul 21, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ambiguous alert var name in specs
- Update and rename appropriately
parent
1b711e20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
34 deletions
+34
-34
spec/finders/alert_management/alerts_finder_spec.rb
spec/finders/alert_management/alerts_finder_spec.rb
+21
-21
spec/graphql/resolvers/alert_management/alert_resolver_spec.rb
...graphql/resolvers/alert_management/alert_resolver_spec.rb
+8
-8
spec/models/alert_management/alert_spec.rb
spec/models/alert_management/alert_spec.rb
+5
-5
No files found.
spec/finders/alert_management/alerts_finder_spec.rb
View file @
03848e84
...
@@ -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
...
...
spec/graphql/resolvers/alert_management/alert_resolver_spec.rb
View file @
03848e84
...
@@ -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
...
...
spec/models/alert_management/alert_spec.rb
View file @
03848e84
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment