Commit 4819e10f authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Move package fixtures to core

Moving dependencies to packages
to core as a step to move
all package feature to core
parent 2ab3b750
...@@ -129,7 +129,7 @@ class Gitlab::Seeder::Packages ...@@ -129,7 +129,7 @@ class Gitlab::Seeder::Packages
end end
def fixture_path(package_type, file) def fixture_path(package_type, file)
Rails.root.join('ee', 'spec', 'fixtures', package_type, file) Rails.root.join('spec', 'fixtures', 'packages', package_type, file)
end end
def with_cloned_fixture_file(package_type, file) def with_cloned_fixture_file(package_type, file)
......
...@@ -126,7 +126,7 @@ FactoryBot.define do ...@@ -126,7 +126,7 @@ FactoryBot.define do
end end
end end
file { fixture_file_upload('ee/spec/fixtures/conan/recipe_files/conanfile.py') } file { fixture_file_upload('spec/fixtures/packages/conan/recipe_files/conanfile.py') }
file_name { 'conanfile.py' } file_name { 'conanfile.py' }
file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
file_md5 { '12345abcde' } file_md5 { '12345abcde' }
...@@ -140,7 +140,7 @@ FactoryBot.define do ...@@ -140,7 +140,7 @@ FactoryBot.define do
end end
end end
file { fixture_file_upload('ee/spec/fixtures/conan/recipe_files/conanmanifest.txt') } file { fixture_file_upload('spec/fixtures/packages/conan/recipe_files/conanmanifest.txt') }
file_name { 'conanmanifest.txt' } file_name { 'conanmanifest.txt' }
file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
file_md5 { '12345abcde' } file_md5 { '12345abcde' }
...@@ -154,7 +154,7 @@ FactoryBot.define do ...@@ -154,7 +154,7 @@ FactoryBot.define do
end end
end end
file { fixture_file_upload('ee/spec/fixtures/conan/package_files/conanmanifest.txt') } file { fixture_file_upload('spec/fixtures/packages/conan/package_files/conanmanifest.txt') }
file_name { 'conanmanifest.txt' } file_name { 'conanmanifest.txt' }
file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
file_md5 { '12345abcde' } file_md5 { '12345abcde' }
...@@ -168,7 +168,7 @@ FactoryBot.define do ...@@ -168,7 +168,7 @@ FactoryBot.define do
end end
end end
file { fixture_file_upload('ee/spec/fixtures/conan/package_files/conaninfo.txt') } file { fixture_file_upload('spec/fixtures/packages/conan/package_files/conaninfo.txt') }
file_name { 'conaninfo.txt' } file_name { 'conaninfo.txt' }
file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
file_md5 { '12345abcde' } file_md5 { '12345abcde' }
...@@ -182,7 +182,7 @@ FactoryBot.define do ...@@ -182,7 +182,7 @@ FactoryBot.define do
end end
end end
file { fixture_file_upload('ee/spec/fixtures/conan/package_files/conan_package.tgz') } file { fixture_file_upload('spec/fixtures/packages/conan/package_files/conan_package.tgz') }
file_name { 'conan_package.tgz' } file_name { 'conan_package.tgz' }
file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
file_md5 { '12345abcde' } file_md5 { '12345abcde' }
...@@ -191,28 +191,28 @@ FactoryBot.define do ...@@ -191,28 +191,28 @@ FactoryBot.define do
end end
trait(:jar) do trait(:jar) do
file { fixture_file_upload('ee/spec/fixtures/maven/my-app-1.0-20180724.124855-1.jar') } file { fixture_file_upload('spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.jar') }
file_name { 'my-app-1.0-20180724.124855-1.jar' } file_name { 'my-app-1.0-20180724.124855-1.jar' }
file_sha1 { '4f0bfa298744d505383fbb57c554d4f5c12d88b3' } file_sha1 { '4f0bfa298744d505383fbb57c554d4f5c12d88b3' }
size { 100.kilobytes } size { 100.kilobytes }
end end
trait(:pom) do trait(:pom) do
file { fixture_file_upload('ee/spec/fixtures/maven/my-app-1.0-20180724.124855-1.pom') } file { fixture_file_upload('spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.pom') }
file_name { 'my-app-1.0-20180724.124855-1.pom' } file_name { 'my-app-1.0-20180724.124855-1.pom' }
file_sha1 { '19c975abd49e5102ca6c74a619f21e0cf0351c57' } file_sha1 { '19c975abd49e5102ca6c74a619f21e0cf0351c57' }
size { 200.kilobytes } size { 200.kilobytes }
end end
trait(:xml) do trait(:xml) do
file { fixture_file_upload('ee/spec/fixtures/maven/maven-metadata.xml') } file { fixture_file_upload('spec/fixtures/packages/maven/maven-metadata.xml') }
file_name { 'maven-metadata.xml' } file_name { 'maven-metadata.xml' }
file_sha1 { '42b1bdc80de64953b6876f5a8c644f20204011b0' } file_sha1 { '42b1bdc80de64953b6876f5a8c644f20204011b0' }
size { 300.kilobytes } size { 300.kilobytes }
end end
trait(:npm) do trait(:npm) do
file { fixture_file_upload('ee/spec/fixtures/npm/foo-1.0.1.tgz') } file { fixture_file_upload('spec/fixtures/packages/npm/foo-1.0.1.tgz') }
file_name { 'foo-1.0.1.tgz' } file_name { 'foo-1.0.1.tgz' }
file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' } file_sha1 { 'be93151dc23ac34a82752444556fe79b32c7a1ad' }
verified_at { Date.current } verified_at { Date.current }
...@@ -222,7 +222,7 @@ FactoryBot.define do ...@@ -222,7 +222,7 @@ FactoryBot.define do
trait(:nuget) do trait(:nuget) do
package package
file { fixture_file_upload('ee/spec/fixtures/nuget/package.nupkg') } file { fixture_file_upload('spec/fixtures/packages/nuget/package.nupkg') }
file_name { 'package.nupkg' } file_name { 'package.nupkg' }
file_sha1 { '5fe852b2a6abd96c22c11fa1ff2fb19d9ce58b57' } file_sha1 { '5fe852b2a6abd96c22c11fa1ff2fb19d9ce58b57' }
size { 300.kilobytes } size { 300.kilobytes }
...@@ -230,7 +230,7 @@ FactoryBot.define do ...@@ -230,7 +230,7 @@ FactoryBot.define do
trait(:pypi) do trait(:pypi) do
package package
file { fixture_file_upload('ee/spec/fixtures/pypi/sample-project.tar.gz') } file { fixture_file_upload('spec/fixtures/packages/pypi/sample-project.tar.gz') }
file_name { 'sample-project-1.0.0.tar.gz' } file_name { 'sample-project-1.0.0.tar.gz' }
file_sha1 { '2c0cfbed075d3fae226f051f0cc771b533e01aff' } file_sha1 { '2c0cfbed075d3fae226f051f0cc771b533e01aff' }
file_md5 { '0a7392d24f42f83068fa3767c5310052' } file_md5 { '0a7392d24f42f83068fa3767c5310052' }
......
...@@ -484,7 +484,7 @@ RSpec.describe API::MavenPackages do ...@@ -484,7 +484,7 @@ RSpec.describe API::MavenPackages do
end end
describe 'PUT /api/v4/projects/:id/packages/maven/*path/:file_name' do describe 'PUT /api/v4/projects/:id/packages/maven/*path/:file_name' do
let(:file_upload) { fixture_file_upload('ee/spec/fixtures/maven/my-app-1.0-20180724.124855-1.jar') } let(:file_upload) { fixture_file_upload('spec/fixtures/packages/maven/my-app-1.0-20180724.124855-1.jar') }
before do before do
# by configuring this path we allow to pass temp file from any path # by configuring this path we allow to pass temp file from any path
......
...@@ -409,7 +409,7 @@ RSpec.describe API::NpmPackages do ...@@ -409,7 +409,7 @@ RSpec.describe API::NpmPackages do
end end
def upload_params(package_name:, package_version: '1.0.1', file: 'npm/payload.json') def upload_params(package_name:, package_version: '1.0.1', file: 'npm/payload.json')
Gitlab::Json.parse(fixture_file(file, dir: 'ee') Gitlab::Json.parse(fixture_file("packages/#{file}")
.gsub('@root/npm-test', package_name) .gsub('@root/npm-test', package_name)
.gsub('1.0.1', package_version)) .gsub('1.0.1', package_version))
end end
......
...@@ -8,9 +8,9 @@ describe Packages::CreateDependencyService do ...@@ -8,9 +8,9 @@ describe Packages::CreateDependencyService do
let_it_be(:package_name) { "@#{namespace.path}/my-app".freeze } let_it_be(:package_name) { "@#{namespace.path}/my-app".freeze }
context 'when packages are published' do context 'when packages are published' do
let(:json_file) { 'npm/payload.json' } let(:json_file) { 'packages/npm/payload.json' }
let(:params) do let(:params) do
Gitlab::Json.parse(fixture_file(json_file, dir: 'ee') Gitlab::Json.parse(fixture_file(json_file)
.gsub('@root/npm-test', package_name) .gsub('@root/npm-test', package_name)
.gsub('1.0.1', version)) .gsub('1.0.1', version))
.with_indifferent_access .with_indifferent_access
...@@ -37,7 +37,7 @@ describe Packages::CreateDependencyService do ...@@ -37,7 +37,7 @@ describe Packages::CreateDependencyService do
end end
context 'with repeated packages' do context 'with repeated packages' do
let(:json_file) { 'npm/payload_with_duplicated_packages.json' } let(:json_file) { 'packages/npm/payload_with_duplicated_packages.json' }
it 'creates dependencies and links' do it 'creates dependencies and links' do
expect(Packages::Dependency) expect(Packages::Dependency)
......
...@@ -8,7 +8,7 @@ describe Packages::Npm::CreatePackageService do ...@@ -8,7 +8,7 @@ describe Packages::Npm::CreatePackageService do
let(:version) { '1.0.1' } let(:version) { '1.0.1' }
let(:params) do let(:params) do
Gitlab::Json.parse(fixture_file('npm/payload.json', dir: 'ee') Gitlab::Json.parse(fixture_file('packages/npm/payload.json')
.gsub('@root/npm-test', package_name) .gsub('@root/npm-test', package_name)
.gsub('1.0.1', version)).with_indifferent_access .gsub('1.0.1', version)).with_indifferent_access
.merge!(override) .merge!(override)
......
...@@ -28,11 +28,11 @@ describe Packages::Nuget::MetadataExtractionService do ...@@ -28,11 +28,11 @@ describe Packages::Nuget::MetadataExtractionService do
context 'with nuspec file' do context 'with nuspec file' do
before do before do
allow(service).to receive(:nuspec_file).and_return(fixture_file(nuspec_filepath, dir: 'ee')) allow(service).to receive(:nuspec_file).and_return(fixture_file(nuspec_filepath))
end end
context 'with dependencies' do context 'with dependencies' do
let(:nuspec_filepath) { 'nuget/with_dependencies.nuspec' } let(:nuspec_filepath) { 'packages/nuget/with_dependencies.nuspec' }
it { is_expected.to have_key(:package_dependencies) } it { is_expected.to have_key(:package_dependencies) }
...@@ -47,17 +47,17 @@ describe Packages::Nuget::MetadataExtractionService do ...@@ -47,17 +47,17 @@ describe Packages::Nuget::MetadataExtractionService do
end end
context 'with a nuspec file with metadata' do context 'with a nuspec file with metadata' do
let(:nuspec_filepath) { 'nuget/with_metadata.nuspec' } let(:nuspec_filepath) { 'packages/nuget/with_metadata.nuspec' }
it { expect(subject[:package_tags].sort).to eq(%w(foo bar test tag1 tag2 tag3 tag4 tag5).sort) } it { expect(subject[:package_tags].sort).to eq(%w(foo bar test tag1 tag2 tag3 tag4 tag5).sort) }
end end
end end
context 'with a nuspec file with metadata' do context 'with a nuspec file with metadata' do
let_it_be(:nuspec_filepath) { 'nuget/with_metadata.nuspec' } let_it_be(:nuspec_filepath) { 'packages/nuget/with_metadata.nuspec' }
before do before do
allow(service).to receive(:nuspec_file).and_return(fixture_file(nuspec_filepath, dir: 'ee')) allow(service).to receive(:nuspec_file).and_return(fixture_file(nuspec_filepath))
end end
it { expect(subject[:license_url]).to eq('https://opensource.org/licenses/MIT') } it { expect(subject[:license_url]).to eq('https://opensource.org/licenses/MIT') }
......
...@@ -111,13 +111,13 @@ describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_ ...@@ -111,13 +111,13 @@ describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_
end end
context 'with a nuspec file with metadata' do context 'with a nuspec file with metadata' do
let(:nuspec_filepath) { 'nuget/with_metadata.nuspec' } let(:nuspec_filepath) { 'packages/nuget/with_metadata.nuspec' }
let(:expected_tags) { %w(foo bar test tag1 tag2 tag3 tag4 tag5) } let(:expected_tags) { %w(foo bar test tag1 tag2 tag3 tag4 tag5) }
before do before do
allow_any_instance_of(Packages::Nuget::MetadataExtractionService) allow_any_instance_of(Packages::Nuget::MetadataExtractionService)
.to receive(:nuspec_file) .to receive(:nuspec_file)
.and_return(fixture_file(nuspec_filepath, dir: 'ee')) .and_return(fixture_file(nuspec_filepath))
end end
it 'creates tags' do it 'creates tags' do
...@@ -164,7 +164,7 @@ describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_ ...@@ -164,7 +164,7 @@ describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_
end end
context 'with nuspec file with dependencies' do context 'with nuspec file with dependencies' do
let(:nuspec_filepath) { 'nuget/with_dependencies.nuspec' } let(:nuspec_filepath) { 'packages/nuget/with_dependencies.nuspec' }
let(:package_name) { 'Test.Package' } let(:package_name) { 'Test.Package' }
let(:package_version) { '3.5.2' } let(:package_version) { '3.5.2' }
let(:package_file_name) { 'test.package.3.5.2.nupkg' } let(:package_file_name) { 'test.package.3.5.2.nupkg' }
...@@ -172,7 +172,7 @@ describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_ ...@@ -172,7 +172,7 @@ describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_redis_
before do before do
allow_any_instance_of(Packages::Nuget::MetadataExtractionService) allow_any_instance_of(Packages::Nuget::MetadataExtractionService)
.to receive(:nuspec_file) .to receive(:nuspec_file)
.and_return(fixture_file(nuspec_filepath, dir: 'ee')) .and_return(fixture_file(nuspec_filepath))
end end
it 'updates package and package file' do it 'updates package and package file' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment