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
cbf279f9
Commit
cbf279f9
authored
Mar 03, 2021
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for UsageMetricDefinitionGenerator
parent
6a072b26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
spec/generator_helper.rb
spec/generator_helper.rb
+15
-0
spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb
...nerators/gitlab/usage_metric_definition_generator_spec.rb
+43
-0
No files found.
spec/generator_helper.rb
0 → 100644
View file @
cbf279f9
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
configure
do
|
config
|
# Redirect stdout so specs don't have so much noise
config
.
before
(
:all
)
do
$stdout
=
StringIO
.
new
end
# Reset stdout
config
.
after
(
:all
)
do
$stdout
=
STDOUT
end
end
spec/lib/generators/gitlab/usage_metric_definition_generator_spec.rb
0 → 100644
View file @
cbf279f9
# frozen_string_literal: true
require
'generator_helper'
RSpec
.
describe
Gitlab
::
UsageMetricDefinitionGenerator
do
describe
'Running generator'
do
let
(
:key_path
)
{
'counter.category.event'
}
let
(
:dir
)
{
'7d'
}
let
(
:options
)
{
[
key_path
,
'--dir'
,
dir
,
'--pretend'
]
}
subject
{
described_class
.
start
(
options
)
}
it
'does not raise an error'
do
expect
{
subject
}.
not_to
raise_error
end
context
'with a missing directory'
do
let
(
:options
)
{
[
key_path
,
'--pretend'
]
}
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
RuntimeError
)
end
end
context
'with an invalid directory'
do
let
(
:dir
)
{
'8d'
}
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
RuntimeError
)
end
end
context
'with an already existing metric with the same key_path'
do
before
do
allow
(
Gitlab
::
Usage
::
MetricDefinition
).
to
receive
(
:definitions
).
and_return
(
Hash
[
key_path
,
'definition'
])
end
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
RuntimeError
)
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