Class: Dri::Commands::Fetch::Testcases

Inherits:
Dri::Command show all
Defined in:
lib/dri/commands/fetch/testcases.rb

Instance Attribute Summary

Attributes inherited from Dri::Command

#config, #emoji, #profile, #timezone, #token, #username

Instance Method Summary collapse

Methods inherited from Dri::Command

#add_color, #api_client, #command, #cursor, #editor, #logger, #pastel, #prompt, #spinner, #verify_config_exists

Constructor Details

#initialize(options) ⇒ Testcases

Returns a new instance of Testcases.



12
13
14
15
# File 'lib/dri/commands/fetch/testcases.rb', line 12

def initialize(options)
  @options = options
  @available_pipelines = %w(main canary master nightly production staging-canary staging-orchestrated staging-ref staging)
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dri/commands/fetch/testcases.rb', line 17

def execute(input: $stdin, output: $stdout)
  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

  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 |pipeline|
      output.puts "#{title_label} #{pipeline["title"]}\n#{url_label} #{pipeline["web_url"]}"
      output.puts "#{divider}\n"
    end 
  end
  
  spinner.stop
end