Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_suite_resolver.rb « ci « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f758e217b470a22c0270d6b45f06cf23d486ea15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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

      argument :build_ids, [GraphQL::Types::ID],
        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|
          build.collect_test_reports!(Gitlab::Ci::Reports::TestReport.new)
        end

        Gitlab::Ci::Reports::TestFailureHistory.new(suite.failed.values, pipeline.project).load!

        suite
      end
    end
  end
end