Skip to content

Commit

Permalink
Validate Testing.Pipeline options (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelonEkonom authored Sep 4, 2023
1 parent 5da3f0d commit 7c52631
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/membrane/testing/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ defmodule Membrane.Testing.Pipeline do
end

defp do_start(type, options) do
:ok = validate_options!(options)

{process_options, options} = Keyword.split(options, [:name])
options = Keyword.put_new(options, :test_process, self())
apply(Pipeline, type, [__MODULE__, options, process_options])
Expand Down Expand Up @@ -528,4 +530,19 @@ defmodule Membrane.Testing.Pipeline do
defp combine_results({custom_actions, custom_state}, {actions, state}) do
{Enum.concat(custom_actions, actions), Map.put(state, :custom_pipeline_state, custom_state)}
end

defp validate_options!(options) do
allowed_keys_1 = [:module, :mode, :spec, :test_process, :name, :raise_on_child_pad_removed?]
allowed_keys_2 = [:module, :custom_args, :test_process, :name]

with {:error, _keys} <- Keyword.validate(options, allowed_keys_1),
{:error, _keys} <- Keyword.validate(options, allowed_keys_2) do
raise """
Options passed to #{inspect(__MODULE__)} start function has to fulfill type
#{inspect(__MODULE__)}.options, while they are #{inspect(options)}
"""
else
{:ok, _keyword} -> :ok
end
end
end

0 comments on commit 7c52631

Please sign in to comment.