Sha256: 348f3a471845a09721d6c6f9b99553654ee70617e64a98a3c13a380b88824bbb

Contents?: true

Size: 1003 Bytes

Versions: 19

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

module GitlabQuality
  module TestTooling
    module TestResults
      class Builder
        def initialize(file_glob:, token: nil, project: nil, ref: 'master')
          @file_glob = file_glob
          @token = token
          @project = project
          @ref = ref
        end

        def test_results_per_file
          Dir.glob(file_glob).each do |path|
            extension = File.extname(path)

            test_results =
              case extension
              when '.json'
                TestResults::JsonTestResults.new(path: path, token: token, project: project, ref: ref)
              when '.xml'
                TestResults::JUnitTestResults.new(path: path, token: token, project: project, ref: ref)
              else
                raise "Unknown extension #{extension}"
              end

            yield test_results
          end
        end

        private

        attr_reader :file_glob, :token, :project, :ref
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-2.5.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-2.4.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-2.3.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-2.2.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-2.1.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-2.0.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.39.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.38.1 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.38.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.37.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.36.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.35.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.34.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.33.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.32.1 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.32.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.31.0 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.29.1 lib/gitlab_quality/test_tooling/test_results/builder.rb
gitlab_quality-test_tooling-1.29.0 lib/gitlab_quality/test_tooling/test_results/builder.rb