debian-mirror-gitlab/spec/services/packages/conan/create_package_service_spec.rb

53 lines
1.5 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Packages::Conan::CreatePackageService do
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