Skip to content

Commit

Permalink
Fi 2413 optional groups prioritize pass (#431)
Browse files Browse the repository at this point in the history
* change priorities for optional groups

* update rspec tests for optional group priorities

* rubocop conformance
  • Loading branch information
Shaumik-Ashraf authored Jan 22, 2024
1 parent 5c35cf6 commit 5405f0b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion dev_suites/dev_infrastructure_test/passing_optional_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ class PassingOptionalGroup < Inferno::TestGroup

optional

test 'Test in Optional Group' do
test 'Passing test in Optional Group' do
optional

run { assert true }
end

test 'Failing test in Optional Group' do
optional

run { assert false }
end
end
end
4 changes: 4 additions & 0 deletions lib/inferno/result_summarizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def initialize(results)
end

def summarize
return 'pass' if all_optional_results? &&
unique_result_strings.any?('pass') &&
unique_result_strings.none? { |result| %w[wait running].include? result }

prioritized_result_strings.find { |result_string| unique_result_strings.include? result_string }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/inferno/dsl/test_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

results = results_repo.current_results_for_test_session(test_session.id)

expect(results.length).to eq(17)
expect(results.length).to eq(18)

required_results = results.reject(&:optional?)
non_passing_results = required_results.reject { |result| result.result == 'pass' }
Expand Down
4 changes: 2 additions & 2 deletions spec/inferno/result_summarizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
end

context 'when all results are optional' do
it 'returns the highest priority result' do
it 'prioritizes passing over failing when a result passes' do
allow(passing_result).to receive(:optional?).and_return(true)
allow(failing_result).to receive(:optional?).and_return(true)
result = described_class.new([passing_result, failing_result]).summarize

expect(result).to eq('fail')
expect(result).to eq('pass')
end
end

Expand Down

0 comments on commit 5405f0b

Please sign in to comment.