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
8e026f25
Commit
8e026f25
authored
Apr 07, 2022
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify test setup
parent
e2e01949
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
29 deletions
+28
-29
spec/requests/api/graphql/ci/runner_spec.rb
spec/requests/api/graphql/ci/runner_spec.rb
+28
-29
No files found.
spec/requests/api/graphql/ci/runner_spec.rb
View file @
8e026f25
...
...
@@ -27,27 +27,14 @@ RSpec.describe 'Query.runner(id)' do
let_it_be
(
:active_project_runner
)
{
create
(
:ci_runner
,
:project
)
}
def
get_runner
(
id
)
case
id
when
:active_instance_runner
active_instance_runner
when
:inactive_instance_runner
inactive_instance_runner
when
:active_group_runner
active_group_runner
when
:active_project_runner
active_project_runner
end
end
shared_examples
'runner details fetch'
do
|
runner_id
|
shared_examples
'runner details fetch'
do
let
(
:query
)
do
wrap_fields
(
query_graphql_path
(
query_path
,
all_graphql_fields_for
(
'CiRunner'
)))
end
let
(
:query_path
)
do
[
[
:runner
,
{
id:
get_runner
(
runner_id
)
.
to_global_id
.
to_s
}]
[
:runner
,
{
id:
runner
.
to_global_id
.
to_s
}]
]
end
...
...
@@ -57,7 +44,6 @@ RSpec.describe 'Query.runner(id)' do
runner_data
=
graphql_data_at
(
:runner
)
expect
(
runner_data
).
not_to
be_nil
runner
=
get_runner
(
runner_id
)
expect
(
runner_data
).
to
match
a_hash_including
(
'id'
=>
runner
.
to_global_id
.
to_s
,
'description'
=>
runner
.
description
,
...
...
@@ -90,14 +76,14 @@ RSpec.describe 'Query.runner(id)' do
end
end
shared_examples
'retrieval with no admin url'
do
|
runner_id
|
shared_examples
'retrieval with no admin url'
do
let
(
:query
)
do
wrap_fields
(
query_graphql_path
(
query_path
,
all_graphql_fields_for
(
'CiRunner'
)))
end
let
(
:query_path
)
do
[
[
:runner
,
{
id:
get_runner
(
runner_id
)
.
to_global_id
.
to_s
}]
[
:runner
,
{
id:
runner
.
to_global_id
.
to_s
}]
]
end
...
...
@@ -107,7 +93,6 @@ RSpec.describe 'Query.runner(id)' do
runner_data
=
graphql_data_at
(
:runner
)
expect
(
runner_data
).
not_to
be_nil
runner
=
get_runner
(
runner_id
)
expect
(
runner_data
).
to
match
a_hash_including
(
'id'
=>
runner
.
to_global_id
.
to_s
,
'adminUrl'
=>
nil
...
...
@@ -116,14 +101,14 @@ RSpec.describe 'Query.runner(id)' do
end
end
shared_examples
'retrieval by unauthorized user'
do
|
runner_id
|
shared_examples
'retrieval by unauthorized user'
do
let
(
:query
)
do
wrap_fields
(
query_graphql_path
(
query_path
,
all_graphql_fields_for
(
'CiRunner'
)))
end
let
(
:query_path
)
do
[
[
:runner
,
{
id:
get_runner
(
runner_id
)
.
to_global_id
.
to_s
}]
[
:runner
,
{
id:
runner
.
to_global_id
.
to_s
}]
]
end
...
...
@@ -135,7 +120,9 @@ RSpec.describe 'Query.runner(id)' do
end
describe
'for active runner'
do
it_behaves_like
'runner details fetch'
,
:active_instance_runner
let
(
:runner
)
{
active_instance_runner
}
it_behaves_like
'runner details fetch'
context
'when tagList is not requested'
do
let
(
:query
)
do
...
...
@@ -144,7 +131,7 @@ RSpec.describe 'Query.runner(id)' do
let
(
:query_path
)
do
[
[
:runner
,
{
id:
active_instance_
runner
.
to_global_id
.
to_s
}]
[
:runner
,
{
id:
runner
.
to_global_id
.
to_s
}]
]
end
...
...
@@ -193,7 +180,9 @@ RSpec.describe 'Query.runner(id)' do
end
describe
'for inactive runner'
do
it_behaves_like
'runner details fetch'
,
:inactive_instance_runner
let
(
:runner
)
{
inactive_instance_runner
}
it_behaves_like
'runner details fetch'
end
describe
'for group runner request'
do
...
...
@@ -369,15 +358,21 @@ RSpec.describe 'Query.runner(id)' do
let
(
:user
)
{
create
(
:user
)
}
context
'on instance runner'
do
it_behaves_like
'retrieval by unauthorized user'
,
:active_instance_runner
let
(
:runner
)
{
active_instance_runner
}
it_behaves_like
'retrieval by unauthorized user'
end
context
'on group runner'
do
it_behaves_like
'retrieval by unauthorized user'
,
:active_group_runner
let
(
:runner
)
{
active_group_runner
}
it_behaves_like
'retrieval by unauthorized user'
end
context
'on project runner'
do
it_behaves_like
'retrieval by unauthorized user'
,
:active_project_runner
let
(
:runner
)
{
active_project_runner
}
it_behaves_like
'retrieval by unauthorized user'
end
end
...
...
@@ -388,13 +383,17 @@ RSpec.describe 'Query.runner(id)' do
group
.
add_user
(
user
,
Gitlab
::
Access
::
OWNER
)
end
it_behaves_like
'retrieval with no admin url'
,
:active_group_runner
it_behaves_like
'retrieval with no admin url'
do
let
(
:runner
)
{
active_group_runner
}
end
end
describe
'by unauthenticated user'
do
let
(
:user
)
{
nil
}
it_behaves_like
'retrieval by unauthorized user'
,
:active_instance_runner
it_behaves_like
'retrieval by unauthorized user'
do
let
(
:runner
)
{
active_instance_runner
}
end
end
describe
'Query limits'
do
...
...
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