Skip to content

Commit

Permalink
comment header for test plan can render via iteration interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Feb 20, 2024
1 parent 1fb6271 commit 4e6eee8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions lib/trailblazer/workflow/iteration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ def initialize(iterations, lanes_cfg:)
end

def to_a
# FIXME: remove?
@iterations
end

def collect(&block)
@iterations.collect(&block)
end

module Serialize
module_function

Expand Down
18 changes: 8 additions & 10 deletions lib/trailblazer/workflow/test/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Plan

# Code fragment with assertions for the discovered/configured test plan.
def for(iteration_set, input:, **options)
code_string = iteration_set.to_a.collect do |iteration|
code_string = iteration_set.collect do |iteration|
event_label = iteration.event_label

%(
Expand All @@ -17,23 +17,21 @@ def for(iteration_set, input:, **options)
end
end

def render_comment_header(discovered_states, **options)
CommentHeader.(discovered_states, **options)
def render_comment_header(iteration_set, **options)
CommentHeader.(iteration_set, **options)
end

module CommentHeader
module_function

def call(discovered_states, **options)
start_position_combined_column = render_combined_column_labels(discovered_states.collect { |row| row[:positions_before][0] }, **options)
expected_position_combined_column = render_combined_column_labels(discovered_states.collect { |row| row[:suspend_configuration].lane_positions }, **options)

rows = discovered_states.collect.with_index do |row, index|
positions_before, start_position = row[:positions_before]
def call(iteration_set, **options)
start_position_combined_column = render_combined_column_labels(iteration_set.collect { |iteration| iteration.start_positions }, **options)
expected_position_combined_column = render_combined_column_labels(iteration_set.collect { |iteration| iteration.suspend_positions }, **options)

rows = iteration_set.collect.with_index do |iteration, index|
Hash[
"triggered catch",
start_position_label(start_position, row, **options),
start_position_label(iteration.start_task_position, iteration, **options),

"start configuration",
start_position_combined_column[index],
Expand Down
4 changes: 3 additions & 1 deletion test/discovery_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ class DiscoveryTestPlanTest < Minitest::Spec
it "render comment header for test plan" do
states, lanes_sorted, lanes_cfg = DiscoveryTest.states()

iteration_set = Trailblazer::Workflow::Iteration::Set.from_discovered_states(states, lanes_cfg: lanes_cfg)

# this usually happens straight after discovery:
test_plan_comment_header = Trailblazer::Workflow::Test::Plan.render_comment_header(states, lanes_cfg: lanes_cfg)
test_plan_comment_header = Trailblazer::Workflow::Test::Plan.render_comment_header(iteration_set, lanes_cfg: lanes_cfg)
puts test_plan_comment_header
assert_equal test_plan_comment_header,
%(+----------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------------+
Expand Down

0 comments on commit 4e6eee8

Please sign in to comment.