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
ed8850a4
Commit
ed8850a4
authored
Jan 14, 2022
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that passed JSON is valid in error tracking service specs
parent
4ff4d3e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
spec/services/error_tracking/collect_error_service_spec.rb
spec/services/error_tracking/collect_error_service_spec.rb
+19
-5
No files found.
spec/services/error_tracking/collect_error_service_spec.rb
View file @
ed8850a4
...
...
@@ -4,8 +4,9 @@ require 'spec_helper'
RSpec
.
describe
ErrorTracking
::
CollectErrorService
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:parsed_event_file
)
{
'error_tracking/parsed_event.json'
}
let_it_be
(
:parsed_event
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
parsed_event_file
))
}
let
(
:parsed_event_file
)
{
'error_tracking/parsed_event.json'
}
let
(
:parsed_event
)
{
parse_valid_event
(
parsed_event_file
)
}
subject
{
described_class
.
new
(
project
,
nil
,
event:
parsed_event
)
}
...
...
@@ -43,7 +44,7 @@ RSpec.describe ErrorTracking::CollectErrorService do
end
context
'python sdk event'
do
let
(
:parsed_event
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'error_tracking/python_event.json'
))
}
let
(
:parsed_event
_file
)
{
'error_tracking/python_event.json'
}
it
'creates a valid event'
do
expect
{
subject
.
execute
}.
to
change
{
ErrorTracking
::
ErrorEvent
.
count
}.
by
(
1
)
...
...
@@ -75,7 +76,7 @@ RSpec.describe ErrorTracking::CollectErrorService do
end
context
'go payload'
do
let
(
:parsed_event
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'error_tracking/go_parsed_event.json'
))
}
let
(
:parsed_event
_file
)
{
'error_tracking/go_parsed_event.json'
}
it
'has correct values set'
do
subject
.
execute
...
...
@@ -94,7 +95,7 @@ RSpec.describe ErrorTracking::CollectErrorService do
end
context
'with two exceptions'
do
let
(
:parsed_event
)
{
Gitlab
::
Json
.
parse
(
fixture_file
(
'error_tracking/go_two_exception_event.json'
))
}
let
(
:parsed_event
_file
)
{
'error_tracking/go_two_exception_event.json'
}
it
'reports using second exception'
,
:aggregate_failures
do
subject
.
execute
...
...
@@ -113,4 +114,17 @@ RSpec.describe ErrorTracking::CollectErrorService do
end
end
end
private
def
parse_valid_event
(
parsed_event_file
)
parsed_event
=
Gitlab
::
Json
.
parse
(
fixture_file
(
parsed_event_file
))
validator
=
ErrorTracking
::
Collector
::
PayloadValidator
.
new
# This a precondition for all specs to verify that
# submitted JSON payload is valid.
expect
(
validator
).
to
be_valid
(
parsed_event
)
parsed_event
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