2020-07-28 23:09:34 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe Packages::Conan::CreatePackageService, feature_category: :package_registry do
|
2020-07-28 23:09:34 +05:30
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
subject(:service) { described_class.new(project, user, params) }
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
describe '#execute' do
|
2020-11-24 15:15:51 +05:30
|
|
|
subject(:package) { service.execute }
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
context 'valid params' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
package_name: 'my-pkg',
|
|
|
|
package_version: '1.0.0',
|
|
|
|
package_username: ::Packages::Conan::Metadatum.package_username_from(full_path: project.full_path),
|
|
|
|
package_channel: 'stable'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a new package' do
|
|
|
|
expect(package).to be_valid
|
|
|
|
expect(package.name).to eq(params[:package_name])
|
|
|
|
expect(package.version).to eq(params[:package_version])
|
|
|
|
expect(package.package_type).to eq('conan')
|
|
|
|
expect(package.conan_metadatum.package_username).to eq(params[:package_username])
|
|
|
|
expect(package.conan_metadatum.package_channel).to eq(params[:package_channel])
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
it_behaves_like 'assigns the package creator'
|
2021-02-22 17:27:13 +05:30
|
|
|
it_behaves_like 'assigns build to package'
|
2021-03-11 19:13:27 +05:30
|
|
|
it_behaves_like 'assigns status to package'
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'invalid params' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
package_name: 'my-pkg',
|
|
|
|
package_version: '1.0.0',
|
|
|
|
package_username: 'foo/bar',
|
|
|
|
package_channel: 'stable'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'fails' do
|
2020-11-24 15:15:51 +05:30
|
|
|
expect { package }.to raise_exception(ActiveRecord::RecordInvalid)
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|