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
5c68f074
Commit
5c68f074
authored
Dec 25, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for package_file_uploader
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
f621783f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
7 deletions
+55
-7
ee/spec/factories/packages.rb
ee/spec/factories/packages.rb
+4
-0
ee/spec/tasks/gitlab/packages/migrate_rake_spec.rb
ee/spec/tasks/gitlab/packages/migrate_rake_spec.rb
+0
-7
ee/spec/uploaders/package_file_uploader_spec.rb
ee/spec/uploaders/package_file_uploader_spec.rb
+44
-0
spec/support/helpers/stub_object_storage.rb
spec/support/helpers/stub_object_storage.rb
+7
-0
No files found.
ee/spec/factories/packages.rb
View file @
5c68f074
...
@@ -61,6 +61,10 @@ FactoryBot.define do
...
@@ -61,6 +61,10 @@ FactoryBot.define do
file_sha1
'f572d396fae9206628714fb2ce00f72e94f2258f'
file_sha1
'f572d396fae9206628714fb2ce00f72e94f2258f'
file_type
'tgz'
file_type
'tgz'
end
end
trait
:object_storage
do
file_store
{
Packages
::
PackageFileUploader
::
Store
::
REMOTE
}
end
end
end
factory
:maven_metadatum
,
class:
Packages
::
MavenMetadatum
do
factory
:maven_metadatum
,
class:
Packages
::
MavenMetadatum
do
...
...
ee/spec/tasks/gitlab/packages/migrate_rake_spec.rb
View file @
5c68f074
...
@@ -34,11 +34,4 @@ describe 'gitlab:packages namespace rake task' do
...
@@ -34,11 +34,4 @@ describe 'gitlab:packages namespace rake task' do
end
end
end
end
end
end
def
stub_packages_object_storage
(
**
params
)
stub_object_storage_uploader
(
config:
Gitlab
.
config
.
packages
.
object_store
,
uploader:
::
Packages
::
PackageFileUploader
,
remote_directory:
'packages'
,
**
params
)
end
end
end
ee/spec/uploaders/package_file_uploader_spec.rb
0 → 100644
View file @
5c68f074
require
'spec_helper'
describe
Packages
::
PackageFileUploader
do
let
(
:package_file
)
{
create
(
:package_file
,
:xml
)
}
let
(
:uploader
)
{
described_class
.
new
(
package_file
,
:file
)
}
let
(
:path
)
{
Gitlab
.
config
.
packages
.
storage_path
}
subject
{
uploader
}
it_behaves_like
"builds correct paths"
,
store_dir:
%r[
\h
{2}/
\h
{2}]
,
cache_dir:
%r[/packages/tmp/cache]
,
work_dir:
%r[/packages/tmp/work]
context
'object store is remote'
do
before
do
stub_packages_object_storage
end
include_context
'with storage'
,
described_class
::
Store
::
REMOTE
it_behaves_like
"builds correct paths"
,
store_dir:
%r[
\h
{2}/
\h
{2}]
end
describe
'remote file'
do
let
(
:package_file
)
{
create
(
:package_file
,
:object_storage
,
:xml
)
}
context
'with object storage enabled'
do
before
do
stub_packages_object_storage
end
it
'can store file remotely'
do
allow
(
ObjectStorage
::
BackgroundMoveWorker
).
to
receive
(
:perform_async
)
package_file
expect
(
package_file
.
file_store
).
to
eq
(
described_class
::
Store
::
REMOTE
)
expect
(
package_file
.
file
.
path
).
not_to
be_blank
end
end
end
end
spec/support/helpers/stub_object_storage.rb
View file @
5c68f074
...
@@ -72,4 +72,11 @@ module StubObjectStorage
...
@@ -72,4 +72,11 @@ module StubObjectStorage
stub_object_storage
(
connection_params:
Pseudonymizer
::
Uploader
.
object_store_credentials
,
stub_object_storage
(
connection_params:
Pseudonymizer
::
Uploader
.
object_store_credentials
,
remote_directory:
Pseudonymizer
::
Uploader
.
remote_directory
)
remote_directory:
Pseudonymizer
::
Uploader
.
remote_directory
)
end
end
def
stub_packages_object_storage
(
**
params
)
stub_object_storage_uploader
(
config:
Gitlab
.
config
.
packages
.
object_store
,
uploader:
::
Packages
::
PackageFileUploader
,
remote_directory:
'packages'
,
**
params
)
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