debian-mirror-gitlab/spec/requests/api/graphql/project/packages_spec.rb

44 lines
1.4 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'getting a package list for a project' do
include GraphqlHelpers
2021-04-17 20:07:23 +05:30
let_it_be(:resource) { create(:project, :repository) }
2020-07-28 23:09:34 +05:30
let_it_be(:current_user) { create(:user) }
2021-03-11 19:13:27 +05:30
2021-04-17 20:07:23 +05:30
let_it_be(:package) { create(:package, project: resource) }
let_it_be(:maven_package) { create(:maven_package, project: resource) }
let_it_be(:debian_package) { create(:debian_package, project: resource) }
let_it_be(:composer_package) { create(:composer_package, project: resource) }
2021-03-11 19:13:27 +05:30
let_it_be(:composer_metadatum) do
create(:composer_metadatum, package: composer_package,
target_sha: 'afdeh',
composer_json: { name: 'x', type: 'y', license: 'z', version: 1 })
end
2021-04-17 20:07:23 +05:30
let(:package_names) { graphql_data_at(:project, :packages, :nodes, :name) }
let(:target_shas) { graphql_data_at(:project, :packages, :nodes, :metadata, :target_sha) }
let(:packages) { graphql_data_at(:project, :packages, :nodes) }
2020-07-28 23:09:34 +05:30
let(:fields) do
<<~QUERY
2021-04-17 20:07:23 +05:30
nodes {
#{all_graphql_fields_for('packages'.classify, excluded: ['project'])}
metadata { #{query_graphql_fragment('ComposerMetadata')} }
2020-07-28 23:09:34 +05:30
}
QUERY
end
let(:query) do
graphql_query_for(
'project',
2021-04-17 20:07:23 +05:30
{ 'fullPath' => resource.full_path },
2020-07-28 23:09:34 +05:30
query_graphql_field('packages', {}, fields)
)
end
2021-04-17 20:07:23 +05:30
it_behaves_like 'group and project packages query'
2020-07-28 23:09:34 +05:30
end