Commit ac53e239 authored by Steve Abrams's avatar Steve Abrams Committed by Robert Speicher

Add BINARY_PACKAGE to conan_file_metadatum

Add filename reference to avoid repeated variables
parent b178a781
......@@ -19,4 +19,5 @@ class Packages::ConanFileMetadatum < ApplicationRecord
RECIPE_FILES = %w[conanfile.py conanmanifest.txt].freeze
PACKAGE_FILES = %w[conaninfo.txt conanmanifest.txt conan_package.tgz].freeze
PACKAGE_BINARY = 'conan_package.tgz'
end
......@@ -187,6 +187,8 @@ module API
delete do
authorize!(:destroy_package, project)
track_event('delete_package')
package.destroy
end
end
......@@ -373,6 +375,8 @@ module API
package_file = ::Packages::PackageFileFinder
.new(package, "#{params[:file_name]}", conan_file_type: file_type).execute!
track_event('pull_package') if params[:file_name] == ::Packages::ConanFileMetadatum::PACKAGE_BINARY
present_carrierwave_file!(package_file.file)
end
......@@ -384,6 +388,8 @@ module API
current_package = package || ::Packages::Conan::CreatePackageService.new(project, current_user, params).execute
track_event('push_package') if params[:file_name] == ::Packages::ConanFileMetadatum::PACKAGE_BINARY && params['file.size'].positive?
# conan sends two upload requests, the first has no file, so we skip record creation if file.size == 0
::Packages::Conan::CreatePackageFileService.new(current_package, uploaded_file, params.merge(conan_file_type: file_type)).execute unless params['file.size'] == 0
rescue ObjectStorage::RemoteStoreError => e
......
......@@ -434,6 +434,8 @@ describe API::ConanPackages do
project.add_maintainer(user)
end
it_behaves_like 'a gitlab tracking event', described_class.name, 'delete_package'
it 'deletes a package' do
expect { subject }.to change { Packages::Package.count }.from(2).to(1)
end
......@@ -546,6 +548,12 @@ describe API::ConanPackages do
it_behaves_like 'an internal project with packages'
it_behaves_like 'a private project with packages'
it_behaves_like 'a project is not found'
context 'tracking the conan_package.tgz download' do
let(:package_file) { package.package_files.find_by(file_name: ::Packages::ConanFileMetadatum::PACKAGE_BINARY) }
it_behaves_like 'a gitlab tracking event', described_class.name, 'pull_package'
end
end
end
......@@ -783,6 +791,11 @@ describe API::ConanPackages do
it_behaves_like 'rejects invalid recipe'
it_behaves_like 'uploads a package file'
context 'tracking the conan_package.tgz upload' do
let(:file_name) { ::Packages::ConanFileMetadatum::PACKAGE_BINARY }
it_behaves_like 'a gitlab tracking event', described_class.name, 'push_package'
end
end
def temp_file(package_tmp)
......
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