Module: DaVinciCRDTestKit::ServerTestHelper

Instance Method Summary collapse

Instance Method Details

#parse_json(input) ⇒ Object



5
6
7
8
# File 'lib/davinci_crd_test_kit/server/server_test_helper.rb', line 5

def parse_json(input)
  assert_valid_json(input)
  JSON.parse(input)
end

#verify_at_least_one_test_passes(test_groups, id_pattern, error_message, id_exclude_pattern = nil) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/davinci_crd_test_kit/server/server_test_helper.rb', line 10

def verify_at_least_one_test_passes(test_groups, id_pattern, error_message, id_exclude_pattern = nil) # rubocop:disable Metrics/CyclomaticComplexity
  runnables = test_groups.map do |group|
    next if ALL_HOOK_TAGS.none? { |hook_name| group.title.include?(hook_name) }

    group.groups[2].tests.find do |test| # response verification subgroup
      test.id.include?(id_pattern) && (!id_exclude_pattern || !test.id.include?(id_exclude_pattern))
    end
  end.compact

  results_repo = Inferno::Repositories::Results.new
  results = results_repo.current_results_for_test_session_and_runnables(test_session_id, runnables)

  pass_if(results.any? { |result| result.result == 'pass' })

  skip error_message
end