Sha256: 76f40f32ce9c0dba932f9bbb00846001c9a2bd390d3f95b71b6f51d394548ed9

Contents?: true

Size: 838 Bytes

Versions: 4

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

require 'json'

module GitlabQuality
  module TestTooling
    module TestResults
      class JsonTestResults < BaseTestResults
        def write
          json = results.merge('examples' => testcases.map(&:report))

          File.write(path, JSON.pretty_generate(json))
        end

        private

        def parse
          JSON.parse(File.read(path))
        rescue JSON::ParserError
          Runtime::Logger.debug("#{self.class.name}##{__method__} attempted to parse invalid JSON at path: #{path}")
          {}
        end

        def process
          return [] if results.empty?

          results['examples'].map do |test|
            GitlabQuality::TestTooling::TestResult::JsonTestResult.new(report: test, project: project, token: token)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-2.5.0 lib/gitlab_quality/test_tooling/test_results/json_test_results.rb
gitlab_quality-test_tooling-2.4.0 lib/gitlab_quality/test_tooling/test_results/json_test_results.rb
gitlab_quality-test_tooling-2.3.0 lib/gitlab_quality/test_tooling/test_results/json_test_results.rb
gitlab_quality-test_tooling-2.2.0 lib/gitlab_quality/test_tooling/test_results/json_test_results.rb