debian-mirror-gitlab/app/graphql/resolvers/ci/test_suite_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
module Resolvers
module Ci
class TestSuiteResolver < BaseResolver
include Gitlab::Graphql::Authorize::AuthorizeResource
type ::Types::Ci::TestSuiteType, null: true
authorize :read_build
authorizes_object!
alias_method :pipeline, :object
2021-10-27 15:23:28 +05:30
argument :build_ids, [GraphQL::Types::ID],
2021-04-29 21:17:54 +05:30
required: true,
description: 'IDs of the builds used to run the test suite.'
def resolve(build_ids:)
builds = pipeline.latest_builds.id_in(build_ids).presence
return unless builds
TestSuiteSerializer
.new(project: pipeline.project, current_user: @current_user)
.represent(load_test_suite_data(builds), details: true)
end
private
def load_test_suite_data(builds)
suite = builds.sum do |build|
2022-08-13 15:12:31 +05:30
build.collect_test_reports!(Gitlab::Ci::Reports::TestReport.new)
2021-04-29 21:17:54 +05:30
end
Gitlab::Ci::Reports::TestFailureHistory.new(suite.failed.values, pipeline.project).load!
suite
end
end
end
end