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
48f72373
Commit
48f72373
authored
Jun 09, 2021
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor instrumentation generator spec
parent
dddc7520
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
28 deletions
+13
-28
spec/lib/generators/gitlab/usage_metric_generator_spec.rb
spec/lib/generators/gitlab/usage_metric_generator_spec.rb
+13
-28
No files found.
spec/lib/generators/gitlab/usage_metric_generator_spec.rb
View file @
48f72373
...
@@ -21,48 +21,33 @@ RSpec.describe Gitlab::UsageMetricGenerator do
...
@@ -21,48 +21,33 @@ RSpec.describe Gitlab::UsageMetricGenerator do
FileUtils
.
rm_rf
([
ce_temp_dir
,
ee_temp_dir
,
spec_ce_temp_dir
,
spec_ee_temp_dir
])
FileUtils
.
rm_rf
([
ce_temp_dir
,
ee_temp_dir
,
spec_ce_temp_dir
,
spec_ee_temp_dir
])
end
end
def
expect_generated_file
(
directory
,
file_name
,
content
)
file_path
=
File
.
join
(
directory
,
file_name
)
file
=
File
.
read
(
file_path
)
expect
(
file
).
to
eq
(
content
)
end
describe
'Creating metric instrumentation files'
do
describe
'Creating metric instrumentation files'
do
let
(
:sample_metric_dir
)
{
'lib/generators/gitlab/usage_metric_generator'
}
let
(
:sample_metric_dir
)
{
'lib/generators/gitlab/usage_metric_generator'
}
let
(
:sample_metric
)
{
fixture_file
(
File
.
join
(
sample_metric_dir
,
'sample_metric.rb'
))
}
let
(
:sample_metric
)
{
fixture_file
(
File
.
join
(
sample_metric_dir
,
'sample_metric.rb'
))
}
let
(
:sample_spec
)
{
fixture_file
(
File
.
join
(
sample_metric_dir
,
'sample_metric_test.rb'
))
}
let
(
:sample_spec
)
{
fixture_file
(
File
.
join
(
sample_metric_dir
,
'sample_metric_test.rb'
))
}
it
'creates CE metric instrumentation file using the template'
do
it
'creates CE metric instrumentation file
s
using the template'
do
described_class
.
new
(
args
,
options
).
invoke_all
described_class
.
new
(
args
,
options
).
invoke_all
file_path
=
File
.
join
(
ce_temp_dir
,
'count_foo_metric.rb'
)
expect_generated_file
(
ce_temp_dir
,
'count_foo_metric.rb'
,
sample_metric
)
file
=
File
.
read
(
file_path
)
expect_generated_file
(
spec_ce_temp_dir
,
'count_foo_metric_spec.rb'
,
sample_spec
)
expect
(
file
).
to
eq
(
sample_metric
)
end
it
'creates CE metric instrumentation spec file using the template'
do
described_class
.
new
(
args
,
options
).
invoke_all
file_path
=
File
.
join
(
spec_ce_temp_dir
,
'count_foo_metric_spec.rb'
)
file
=
File
.
read
(
file_path
)
expect
(
file
).
to
eq
(
sample_spec
)
end
end
context
'with EE flag true'
do
context
'with EE flag true'
do
let
(
:options
)
{
{
'type'
=>
'redis_hll'
,
'ee'
=>
true
}
}
let
(
:options
)
{
{
'type'
=>
'redis_hll'
,
'ee'
=>
true
}
}
it
'creates EE metric instrumentation file using the template'
do
it
'creates EE metric instrumentation file
s
using the template'
do
described_class
.
new
(
args
,
options
).
invoke_all
described_class
.
new
(
args
,
options
).
invoke_all
file_path
=
File
.
join
(
ee_temp_dir
,
'count_foo_metric.rb'
)
expect_generated_file
(
ee_temp_dir
,
'count_foo_metric.rb'
,
sample_metric
)
file
=
File
.
read
(
file_path
)
expect_generated_file
(
spec_ee_temp_dir
,
'count_foo_metric_spec.rb'
,
sample_spec
)
expect
(
file
).
to
eq
(
sample_metric
)
end
it
'creates EE metric instrumentation spec file using the template'
do
described_class
.
new
(
args
,
options
).
invoke_all
file_path
=
File
.
join
(
spec_ee_temp_dir
,
'count_foo_metric_spec.rb'
)
file
=
File
.
read
(
file_path
)
expect
(
file
).
to
eq
(
sample_spec
)
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