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
347bce29
Commit
347bce29
authored
Nov 23, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve specs for uploaders
parent
20462ea0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
11 deletions
+27
-11
spec/uploaders/job_artifact_uploader_spec.rb
spec/uploaders/job_artifact_uploader_spec.rb
+25
-9
spec/uploaders/legacy_artifact_uploader_spec.rb
spec/uploaders/legacy_artifact_uploader_spec.rb
+2
-2
No files found.
spec/uploaders/job_artifact_uploader_spec.rb
View file @
347bce29
require
'spec_helper'
require
'spec_helper'
describe
JobArtifactUploader
do
describe
JobArtifactUploader
do
set
(
:job_artifact
)
{
create
(
:ci_job_artifact
)
}
let
(
:store
)
{
described_class
::
LOCAL_STORE
}
let
(
:job_artifact
)
{
create
(
:ci_job_artifact
,
file_store:
store
)
}
let
(
:uploader
)
{
described_class
.
new
(
job_artifact
,
:file
)
}
let
(
:uploader
)
{
described_class
.
new
(
job_artifact
,
:file
)
}
let
(
:path
)
{
Gitlab
.
config
.
artifacts
.
path
}
let
(
:
local_
path
)
{
Gitlab
.
config
.
artifacts
.
path
}
describe
'#store_dir'
do
describe
'#store_dir'
do
subject
{
uploader
.
store_dir
}
subject
{
uploader
.
store_dir
}
it
{
is_expected
.
to
start_with
(
path
)
}
let
(
:path
)
{
"
#{
job_artifact
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
}
/
#{
job_artifact
.
project_id
}
/
#{
job_artifact
.
id
}
"
}
it
{
is_expected
.
not_to
end_with
(
"
#{
job_artifact
.
project_id
}
/
#{
job_artifact
.
created_at
.
utc
.
strftime
(
'%Y_%m'
)
}
/
#{
job_artifact
.
id
}
"
)
}
it
{
is_expected
.
to
match
(
/\h{2}\/\h{2}\/\h{64}\/\d{4}_\d{1,2}_\d{1,2}\/\d+\/\d+\z/
)
}
context
'when using local storage'
do
it
{
is_expected
.
to
start_with
(
local_path
)
}
it
{
is_expected
.
to
match
(
/\h{2}\/\h{2}\/\h{64}\/\d{4}_\d{1,2}_\d{1,2}\/\d+\/\d+\z/
)
}
it
{
is_expected
.
to
end_with
(
path
)
}
end
context
'when using remote storage'
do
let
(
:store
)
{
described_class
::
REMOTE_STORE
}
before
do
stub_artifacts_object_storage
end
it
{
is_expected
.
to
match
(
/\h{2}\/\h{2}\/\h{64}\/\d{4}_\d{1,2}_\d{1,2}\/\d+\/\d+\z/
)
}
it
{
is_expected
.
to
end_with
(
path
)
}
end
end
end
describe
'#cache_dir'
do
describe
'#cache_dir'
do
subject
{
uploader
.
cache_dir
}
subject
{
uploader
.
cache_dir
}
it
{
is_expected
.
to
start_with
(
path
)
}
it
{
is_expected
.
to
start_with
(
local_
path
)
}
it
{
is_expected
.
to
end_with
(
'/tmp/cache'
)
}
it
{
is_expected
.
to
end_with
(
'/tmp/cache'
)
}
end
end
describe
'#work_dir'
do
describe
'#work_dir'
do
subject
{
uploader
.
work_dir
}
subject
{
uploader
.
work_dir
}
it
{
is_expected
.
to
start_with
(
path
)
}
it
{
is_expected
.
to
start_with
(
local_
path
)
}
it
{
is_expected
.
to
end_with
(
'/tmp/work'
)
}
it
{
is_expected
.
to
end_with
(
'/tmp/work'
)
}
end
end
context
'file is stored in valid path'
do
context
'file is stored in valid
local_
path'
do
let
(
:file
)
do
let
(
:file
)
do
fixture_file_upload
(
Rails
.
root
.
join
(
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts.zip'
),
'application/zip'
)
'spec/fixtures/ci_build_artifacts.zip'
),
'application/zip'
)
...
@@ -39,7 +55,7 @@ describe JobArtifactUploader do
...
@@ -39,7 +55,7 @@ describe JobArtifactUploader do
subject
{
uploader
.
file
.
path
}
subject
{
uploader
.
file
.
path
}
it
{
is_expected
.
to
start_with
(
path
)
}
it
{
is_expected
.
to
start_with
(
local_
path
)
}
it
{
is_expected
.
to
include
(
"/
#{
job_artifact
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
}
/"
)
}
it
{
is_expected
.
to
include
(
"/
#{
job_artifact
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
}
/"
)
}
it
{
is_expected
.
to
include
(
"/
#{
job_artifact
.
project_id
.
to_s
}
/"
)
}
it
{
is_expected
.
to
include
(
"/
#{
job_artifact
.
project_id
.
to_s
}
/"
)
}
it
{
is_expected
.
to
end_with
(
"ci_build_artifacts.zip"
)
}
it
{
is_expected
.
to
end_with
(
"ci_build_artifacts.zip"
)
}
...
...
spec/uploaders/legacy_artifact_uploader_spec.rb
View file @
347bce29
...
@@ -3,7 +3,7 @@ require 'rails_helper'
...
@@ -3,7 +3,7 @@ require 'rails_helper'
describe
LegacyArtifactUploader
do
describe
LegacyArtifactUploader
do
let
(
:store
)
{
described_class
::
LOCAL_STORE
}
let
(
:store
)
{
described_class
::
LOCAL_STORE
}
let
(
:job
)
{
create
(
:ci_build
,
artifacts_file_store:
store
)
}
let
(
:job
)
{
create
(
:ci_build
,
artifacts_file_store:
store
)
}
let
(
:uploader
)
{
described_class
.
new
(
job
,
:artifacts_file
)
}
let
(
:uploader
)
{
described_class
.
new
(
job
,
:
legacy_
artifacts_file
)
}
let
(
:local_path
)
{
Gitlab
.
config
.
artifacts
.
path
}
let
(
:local_path
)
{
Gitlab
.
config
.
artifacts
.
path
}
describe
'.local_store_path'
do
describe
'.local_store_path'
do
...
@@ -80,7 +80,7 @@ describe LegacyArtifactUploader do
...
@@ -80,7 +80,7 @@ describe LegacyArtifactUploader do
subject
{
uploader
.
file
.
path
}
subject
{
uploader
.
file
.
path
}
it
{
is_expected
.
to
start_with
(
path
)
}
it
{
is_expected
.
to
start_with
(
local_
path
)
}
it
{
is_expected
.
to
include
(
"/
#{
job
.
created_at
.
utc
.
strftime
(
'%Y_%m'
)
}
/"
)
}
it
{
is_expected
.
to
include
(
"/
#{
job
.
created_at
.
utc
.
strftime
(
'%Y_%m'
)
}
/"
)
}
it
{
is_expected
.
to
include
(
"/
#{
job
.
project_id
.
to_s
}
/"
)
}
it
{
is_expected
.
to
include
(
"/
#{
job
.
project_id
.
to_s
}
/"
)
}
it
{
is_expected
.
to
end_with
(
"ci_build_artifacts.zip"
)
}
it
{
is_expected
.
to
end_with
(
"ci_build_artifacts.zip"
)
}
...
...
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