Module: Inferno::Utils::PersistInputs

Included in:
CLI::Execute, Web::Controllers::TestRuns::Create
Defined in:
lib/inferno/utils/persist_inputs.rb

Instance Method Summary collapse

Instance Method Details

#persist_inputs(session_data_repo, params, test_run) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/inferno/utils/persist_inputs.rb', line 5

def persist_inputs(session_data_repo, params, test_run)
  available_inputs = test_run.runnable.available_inputs
  params[:inputs]&.each do |input_params|
    input =
      available_inputs
        .find { |_, runnable_input| runnable_input.name == input_params[:name] }
        &.last

    if input.nil?
      Inferno::Application['logger'].warn(
        "Unknown input `#{input_params[:name]}` for #{test_run.runnable.id}: #{test_run.runnable.title}"
      )
      next
    end

    session_data_repo.save(
      test_session_id: test_run.test_session_id,
      name: input.name,
      value: input_params[:value],
      type: input.type
    )
  end
end