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
708ebe38
Commit
708ebe38
authored
Dec 22, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Primary supports api/transfers/job_artifact/:id
parent
6e368017
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
0 deletions
+87
-0
ee/lib/gitlab/geo/job_artifact_uploader.rb
ee/lib/gitlab/geo/job_artifact_uploader.rb
+19
-0
spec/ee/spec/lib/gitlab/geo/job_artifact_uploader_spec.rb
spec/ee/spec/lib/gitlab/geo/job_artifact_uploader_spec.rb
+45
-0
spec/ee/spec/services/geo/file_upload_service_spec.rb
spec/ee/spec/services/geo/file_upload_service_spec.rb
+23
-0
No files found.
ee/lib/gitlab/geo/job_artifact_uploader.rb
0 → 100644
View file @
708ebe38
module
Gitlab
module
Geo
class
JobArtifactUploader
<
FileUploader
def
execute
job_artifact
=
::
Ci
::
JobArtifact
.
find_by
(
id:
object_db_id
)
unless
job_artifact
.
present?
return
error
(
'Job artifact not found'
)
end
unless
job_artifact
.
file
.
present?
&&
job_artifact
.
file
.
exists?
return
error
(
'Job artifact does not have a file'
)
end
success
(
job_artifact
.
file
)
end
end
end
end
spec/ee/spec/lib/gitlab/geo/job_artifact_uploader_spec.rb
0 → 100644
View file @
708ebe38
require
'spec_helper'
describe
Gitlab
::
Geo
::
JobArtifactUploader
,
:geo
do
context
'#execute'
do
subject
{
described_class
.
new
(
job_artifact
.
id
,
{}).
execute
}
context
'when the job artifact exists'
do
before
do
expect
(
::
Ci
::
JobArtifact
).
to
receive
(
:find_by
).
with
(
id:
job_artifact
.
id
).
and_return
(
job_artifact
)
end
context
'when the job artifact is an archive file_type and has a file'
do
let
(
:job_artifact
)
{
create
(
:ci_job_artifact
,
:archive
)
}
it
'returns the file in a success hash'
do
expect
(
subject
).
to
eq
(
code: :ok
,
message:
'Success'
,
file:
job_artifact
.
file
)
end
end
context
'when the job artifact is an metadata file_type and has a file'
do
let
(
:job_artifact
)
{
create
(
:ci_job_artifact
,
:metadata
)
}
it
'returns the file in a success hash'
do
expect
(
subject
).
to
eq
(
code: :ok
,
message:
'Success'
,
file:
job_artifact
.
file
)
end
end
context
'when the job artifact does not have a file'
do
let
(
:job_artifact
)
{
create
(
:ci_job_artifact
)
}
it
'returns an error hash'
do
expect
(
subject
).
to
eq
(
code: :not_found
,
message:
"Job artifact does not have a file"
)
end
end
end
context
'when the job artifact does not exist'
do
let
(
:job_artifact
)
{
double
(
id:
10000
)
}
it
'returns an error hash'
do
expect
(
subject
).
to
eq
(
code: :not_found
,
message:
"Job artifact not found"
)
end
end
end
end
spec/ee/spec/services/geo/file_upload_service_spec.rb
View file @
708ebe38
...
...
@@ -180,5 +180,28 @@ describe Geo::FileUploadService do
expect
(
service
.
execute
).
to
be_nil
end
end
context
'job artifact'
do
let
(
:job_artifact
)
{
create
(
:ci_job_artifact
,
:with_file
)
}
let
(
:params
)
{
{
id:
job_artifact
.
id
,
type:
'job_artifact'
}
}
let
(
:job_artifact_transfer
)
{
Gitlab
::
Geo
::
JobArtifactTransfer
.
new
(
job_artifact
)
}
let
(
:transfer_request
)
{
Gitlab
::
Geo
::
TransferRequest
.
new
(
job_artifact_transfer
.
request_data
)
}
let
(
:req_header
)
{
transfer_request
.
headers
[
'Authorization'
]
}
it
'sends job artifact file'
do
service
=
described_class
.
new
(
params
,
req_header
)
response
=
service
.
execute
expect
(
response
[
:code
]).
to
eq
(
:ok
)
expect
(
response
[
:file
].
path
).
to
eq
(
job_artifact
.
file
.
path
)
end
it
'returns nil if no authorization'
do
service
=
described_class
.
new
(
params
,
nil
)
expect
(
service
.
execute
).
to
be_nil
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