Sha256: 96d1ede06cebf1025069b36def1f0ec96d953a90c42c92dc4368c63f8a588d89

Contents?: true

Size: 1.7 KB

Versions: 8

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

require_relative '../../command'

require 'pastel'

module Dri
  module Commands
    class Fetch
      class Testcases < Dri::Command
        def initialize(options)
          @options = options
          @available_pipelines = %w[
            main
            canary
            master
            nightly
            production
            staging-canary
            staging-ref
            staging
          ]
        end

        def execute(input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize
          verify_config_exists

          if @options[:filter_pipelines]
            filtered_pipelines = prompt.multi_select("Select pipelines:", @available_pipelines)
          end

          logger.info "Fetching currently failing testcases..."

          title_label = add_color('Title:', :bright_yellow)
          url_label = add_color('URL:', :bright_yellow)
          divider = add_color('---', :cyan)

          spinner.start

          pipelines = @options[:filter_pipelines] ? filtered_pipelines : @available_pipelines

          logger.error "No pipelines selected to continue to fetch testcases." if pipelines.empty?

          pipelines.each do |pipeline|
            logger.info "Fetching failing testcases in #{pipeline}\n"
            response = api_client.fetch_failing_testcases(pipeline, state: 'opened')

            output.puts "♦♦♦♦♦ #{add_color(pipeline, :black, :on_white)}♦♦♦♦♦\n\n"

            response.each do |test_case|
              output.puts "#{title_label} #{test_case.title}\n#{url_label} #{test_case.web_url}"
              output.puts "#{divider}\n"
            end
          end

          spinner.stop
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dri-0.9.0 lib/dri/commands/fetch/testcases.rb
dri-0.8.0 lib/dri/commands/fetch/testcases.rb
dri-0.7.0 lib/dri/commands/fetch/testcases.rb
dri-0.6.1 lib/dri/commands/fetch/testcases.rb
dri-0.6.0 lib/dri/commands/fetch/testcases.rb
dri-0.5.1 lib/dri/commands/fetch/testcases.rb
dri-0.5.0 lib/dri/commands/fetch/testcases.rb
dri-0.4.0 lib/dri/commands/fetch/testcases.rb