Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
nexedi
gitlab-shell
Commits
14738fae
Commit
14738fae
authored
Sep 13, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
primary_repo can be a String or a Hash
parent
4656cd71
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
34 deletions
+44
-34
spec/action/custom_spec.rb
spec/action/custom_spec.rb
+44
-34
No files found.
spec/action/custom_spec.rb
View file @
14738fae
...
@@ -26,52 +26,62 @@ describe Action::Custom do
...
@@ -26,52 +26,62 @@ describe Action::Custom do
end
end
context
'that are valid'
do
context
'that are valid'
do
let
(
:payload
)
do
where
(
:primary_repo_data
)
do
{
[
'action'
=>
'geo_proxy_to_primary'
,
[
'http://localhost:3001/user1/repo1.git'
],
'data'
=>
{
[{
'http'
=>
'http://localhost:3001/user1/repo1.git'
}],
'api_endpoints'
=>
%w{/api/v4/fake/info_refs /api/v4/fake/push}
,
[{
'http'
=>
'http://localhost:3001/user1/repo1.git'
,
'ssh'
=>
'ssh://user@localhost:3002/user1/repo1.git'
}]
'gl_username'
=>
'user1'
,
]
'primary_repo'
=>
'http://localhost:3001/user1/repo1.git'
}
}
end
end
context
'and responds correctly'
do
with_them
do
it
'prints a Base64 encoded result to $stdout'
do
let
(
:payload
)
do
VCR
.
use_cassette
(
"custom-action-ok"
)
do
{
expect
(
$stdout
).
to
receive
(
:print
).
with
(
'info_refs-result'
).
ordered
'action'
=>
'geo_proxy_to_primary'
,
expect
(
$stdout
).
to
receive
(
:print
).
with
(
'push-result'
).
ordered
'data'
=>
{
subject
.
execute
'api_endpoints'
=>
%w{/api/v4/fake/info_refs /api/v4/fake/push}
,
end
'gl_username'
=>
'user1'
,
'primary_repo'
=>
primary_repo_data
}
}
end
end
context
'with results printed to $stdout'
do
context
'and responds correctly'
do
before
do
it
'prints a Base64 encoded result to $stdout'
do
allow
(
$stdout
).
to
receive
(
:print
).
with
(
'info_refs-result'
)
VCR
.
use_cassette
(
"custom-action-ok"
)
do
allow
(
$stdout
).
to
receive
(
:print
).
with
(
'push-result'
)
expect
(
$stdout
).
to
receive
(
:print
).
with
(
'info_refs-result'
).
ordered
expect
(
$stdout
).
to
receive
(
:print
).
with
(
'push-result'
).
ordered
subject
.
execute
end
end
end
it
'prints a message to $stderr'
do
context
'with results printed to $stdout'
do
VCR
.
use_cassette
(
"custom-action-ok-with-message"
)
do
before
do
expect
{
subject
.
execute
}.
to
output
(
/NOTE: Message here/
).
to_stderr
allow
(
$stdout
).
to
receive
(
:print
).
with
(
'info_refs-result'
)
allow
(
$stdout
).
to
receive
(
:print
).
with
(
'push-result'
)
end
end
end
it
'returns an instance of Net::HTTPCreated'
do
it
'prints a message to $stderr'
do
VCR
.
use_cassette
(
"custom-action-ok"
)
do
VCR
.
use_cassette
(
"custom-action-ok-with-message"
)
do
expect
(
subject
.
execute
).
to
be_instance_of
(
Net
::
HTTPCreated
)
expect
{
subject
.
execute
}.
to
output
(
/NOTE: Message here/
).
to_stderr
end
end
it
'returns an instance of Net::HTTPCreated'
do
VCR
.
use_cassette
(
"custom-action-ok"
)
do
expect
(
subject
.
execute
).
to
be_instance_of
(
Net
::
HTTPCreated
)
end
end
end
end
end
end
end
end
context
'but responds incorrectly'
do
context
'but responds incorrectly'
do
it
'raises an UnsuccessfulError exception'
do
it
'raises an UnsuccessfulError exception'
do
VCR
.
use_cassette
(
"custom-action-ok-not-json"
)
do
VCR
.
use_cassette
(
"custom-action-ok-not-json"
)
do
expect
{
expect
{
subject
.
execute
subject
.
execute
}.
to
raise_error
(
Action
::
Custom
::
UnsuccessfulError
,
'Response was not valid JSON'
)
}.
to
raise_error
(
Action
::
Custom
::
UnsuccessfulError
,
'Response was not valid JSON'
)
end
end
end
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