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
7f780046
Commit
7f780046
authored
Jan 08, 2019
by
ddavison
Committed by
Sanad Liaquat
Jan 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs to remote grid. Raise errors for #remote_grid_credentials
Signed-off-by:
ddavison
<
ddavison@gitlab.com
>
parent
8677d408
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
qa/qa/runtime/env.rb
qa/qa/runtime/env.rb
+7
-1
qa/spec/runtime/env_spec.rb
qa/spec/runtime/env_spec.rb
+59
-0
No files found.
qa/qa/runtime/env.rb
View file @
7f780046
...
...
@@ -187,7 +187,13 @@ module QA
private
def
remote_grid_credentials
remote_grid_username
?
"
#{
remote_grid_username
}
:
#{
remote_grid_access_key
}
@"
:
''
if
remote_grid_username
raise
ArgumentError
,
%Q(Please provide an access key for user "
#{
remote_grid_username
}
")
unless
remote_grid_access_key
return
"
#{
remote_grid_username
}
:
#{
remote_grid_access_key
}
@"
end
''
end
def
enabled?
(
value
,
default:
true
)
...
...
qa/spec/runtime/env_spec.rb
View file @
7f780046
...
...
@@ -207,4 +207,63 @@ describe QA::Runtime::Env do
expect
{
described_class
.
can_test?
:foo
}.
to
raise_error
(
ArgumentError
,
'Unknown feature "foo"'
)
end
end
describe
'remote grid credentials'
do
it
'is blank if username is empty'
do
stub_env
(
'QA_REMOTE_GRID_USERNAME'
,
nil
)
expect
(
described_class
.
send
(
:remote_grid_credentials
)).
to
eq
(
''
)
end
it
'throws ArgumentError if GRID_ACCESS_KEY is not specified with USERNAME'
do
stub_env
(
'QA_REMOTE_GRID_USERNAME'
,
'foo'
)
expect
{
described_class
.
send
(
:remote_grid_credentials
)
}.
to
raise_error
(
ArgumentError
,
'Please provide an access key for user "foo"'
)
end
it
'returns a user:key@ combination when all args are satiated'
do
stub_env
(
'QA_REMOTE_GRID_USERNAME'
,
'foo'
)
stub_env
(
'QA_REMOTE_GRID_ACCESS_KEY'
,
'bar'
)
expect
(
described_class
.
send
(
:remote_grid_credentials
)).
to
eq
(
'foo:bar@'
)
end
end
describe
'.remote_grid_protocol'
do
it
'defaults protocol to http'
do
stub_env
(
'QA_REMOTE_GRID_PROTOCOL'
,
nil
)
expect
(
described_class
.
remote_grid_protocol
).
to
eq
(
'http'
)
end
end
describe
'.remote_grid'
do
it
'is falsey if QA_REMOTE_GRID is not set'
do
expect
(
described_class
.
remote_grid
).
to
be_falsey
end
it
'accepts https protocol'
do
stub_env
(
'QA_REMOTE_GRID'
,
'localhost:4444'
)
stub_env
(
'QA_REMOTE_GRID_PROTOCOL'
,
'https'
)
expect
(
described_class
.
remote_grid
).
to
eq
(
'https://localhost:4444/wd/hub'
)
end
context
'with credentials'
do
it
'has a grid of http://user:key@grid/wd/hub'
do
stub_env
(
'QA_REMOTE_GRID_USERNAME'
,
'foo'
)
stub_env
(
'QA_REMOTE_GRID_ACCESS_KEY'
,
'bar'
)
stub_env
(
'QA_REMOTE_GRID'
,
'localhost:4444'
)
expect
(
described_class
.
remote_grid
).
to
eq
(
'http://foo:bar@localhost:4444/wd/hub'
)
end
end
context
'without credentials'
do
it
'has a grid of http://grid/wd/hub'
do
stub_env
(
'QA_REMOTE_GRID'
,
'localhost:4444'
)
expect
(
described_class
.
remote_grid
).
to
eq
(
'http://localhost:4444/wd/hub'
)
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