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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
d0352e66
Commit
d0352e66
authored
Dec 14, 2015
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for MetricsWorker
parent
f932b781
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
spec/workers/metrics_worker_spec.rb
spec/workers/metrics_worker_spec.rb
+40
-0
No files found.
spec/workers/metrics_worker_spec.rb
0 → 100644
View file @
d0352e66
require
'spec_helper'
describe
MetricsWorker
do
let
(
:worker
)
{
described_class
.
new
}
describe
'#perform'
do
it
'prepares and writes the metrics to InfluxDB'
do
connection
=
double
(
:connection
)
pool
=
double
(
:pool
)
expect
(
pool
).
to
receive
(
:with
).
and_yield
(
connection
)
expect
(
connection
).
to
receive
(
:write_points
).
with
(
an_instance_of
(
Array
))
expect
(
Gitlab
::
Metrics
).
to
receive
(
:pool
).
and_return
(
pool
)
worker
.
perform
([{
'series'
=>
'kittens'
,
'tags'
=>
{}
}])
end
end
describe
'#prepare_metrics'
do
it
'returns a Hash with the keys as Symbols'
do
metrics
=
worker
.
prepare_metrics
([{
'values'
=>
{},
'tags'
=>
{}
}])
expect
(
metrics
).
to
eq
([{
values:
{},
tags:
{}
}])
end
it
'escapes tag values'
do
metrics
=
worker
.
prepare_metrics
([
{
'values'
=>
{},
'tags'
=>
{
'foo'
=>
'bar='
}
}
])
expect
(
metrics
).
to
eq
([{
values:
{},
tags:
{
'foo'
=>
'bar\\='
}
}])
end
end
describe
'#escape_value'
do
it
'escapes an equals sign'
do
expect
(
worker
.
escape_value
(
'foo='
)).
to
eq
(
'foo\\='
)
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