diff --git a/.formatter.exs b/.formatter.exs index 376fc86..958614f 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,5 +1,6 @@ # Used by "mix format" [ inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], - import_deps: [:typed_struct] + import_deps: [:typed_struct], + plugins: [Styler] ] diff --git a/lib/workflow_metal/application/config.ex b/lib/workflow_metal/application/config.ex index 50f90ae..8bb2d26 100644 --- a/lib/workflow_metal/application/config.ex +++ b/lib/workflow_metal/application/config.ex @@ -1,11 +1,15 @@ defmodule WorkflowMetal.Application.Config do @moduledoc false - @type t :: map() - @type application :: WorkflowMetal.Application.t() + @type t() :: map() + @type application() :: WorkflowMetal.Application.t() + + @typep key() :: atom() + @typep value() :: term() + # credo:disable-for-previous-line JetCredo.Checks.ExplicitAnyType @doc false - @spec start_link(application, t) :: Agent.on_start() + @spec start_link(application(), t()) :: Agent.on_start() def start_link(application, initial_value) do Agent.start_link(fn -> initial_value end, name: config_name(application)) end @@ -13,7 +17,7 @@ defmodule WorkflowMetal.Application.Config do @doc """ Store settings of an application. """ - @spec set(application, atom, term) :: :ok + @spec set(application(), key(), value()) :: :ok def set(application, key, value) when is_atom(application) do Agent.update(config_name(application), fn state -> Keyword.put(state, key, value) @@ -23,7 +27,7 @@ defmodule WorkflowMetal.Application.Config do @doc """ Retrieve settings of an application. """ - @spec get(application, atom) :: term + @spec get(application(), key()) :: value() def get(application, key) when is_atom(application) and is_atom(key) do Agent.get(config_name(application), fn state -> Keyword.get(state, key) @@ -33,11 +37,13 @@ defmodule WorkflowMetal.Application.Config do @doc """ Retrieves the compile time configuration. """ + @spec compile_config(application(), Keyword.t()) :: Keyword.t() def compile_config(_application, config) do Keyword.take(config, [:name, :registry, :storage]) end defp config_name(application) do + # credo:disable-for-next-line Credo.Check.Warning.UnsafeToAtom Module.concat(application, Config) end end diff --git a/lib/workflow_metal/application/supervisor.ex b/lib/workflow_metal/application/supervisor.ex index d61cf8a..fb981bd 100644 --- a/lib/workflow_metal/application/supervisor.ex +++ b/lib/workflow_metal/application/supervisor.ex @@ -25,14 +25,12 @@ defmodule WorkflowMetal.Application.Supervisor do config_child_spec = config_child_spec(application, config) - children = - [ - config_child_spec, - registry_child_spec, - storage_child_spec, - {WorkflowMetal.Application.WorkflowsSupervisor, application} - ] - |> Enum.filter(& &1) + children = [ + config_child_spec, + registry_child_spec, + storage_child_spec, + {WorkflowMetal.Application.WorkflowsSupervisor, application} + ] Supervisor.init(children, strategy: :one_for_one) end diff --git a/lib/workflow_metal/application/workflows_supervisor.ex b/lib/workflow_metal/application/workflows_supervisor.ex index 7234d48..205ae1d 100644 --- a/lib/workflow_metal/application/workflows_supervisor.ex +++ b/lib/workflow_metal/application/workflows_supervisor.ex @@ -40,9 +40,7 @@ defmodule WorkflowMetal.Application.WorkflowsSupervisor do WorkflowMetal.Registration.Adapter.on_start_child() | {:error, :workflow_not_found} def open_workflow(application, workflow_id) do - with( - {:ok, workflow_schema} <- WorkflowMetal.Storage.fetch_workflow(application, workflow_id) - ) do + with({:ok, workflow_schema} <- WorkflowMetal.Storage.fetch_workflow(application, workflow_id)) do workflows_supervisor = supervisor_name(application) workflow_supervisor = {WorkflowMetal.Workflow.Supervisor, workflow_id: workflow_schema.id} diff --git a/lib/workflow_metal/case/case.ex b/lib/workflow_metal/case/case.ex index 2011963..5aecfc4 100644 --- a/lib/workflow_metal/case/case.ex +++ b/lib/workflow_metal/case/case.ex @@ -801,7 +801,10 @@ defmodule WorkflowMetal.Case.Case do state: [:started, :allocated, :executing] ) - Enum.each(tasks, fn task -> WorkflowMetal.Task.Supervisor.force_abandon_task(application, task.id) end) + Enum.each(tasks, fn task -> + WorkflowMetal.Task.Supervisor.force_abandon_task(application, task.id) + end) + data end diff --git a/lib/workflow_metal/controller/join/and.ex b/lib/workflow_metal/controller/join/and.ex index 05c51b4..2fa2a13 100644 --- a/lib/workflow_metal/controller/join/and.ex +++ b/lib/workflow_metal/controller/join/and.ex @@ -3,10 +3,10 @@ defmodule WorkflowMetal.Controller.Join.And do All incoming branch are active. """ - alias WorkflowMetal.Storage.Schema - @behaviour WorkflowMetal.Controller.Join + alias WorkflowMetal.Storage.Schema + @impl WorkflowMetal.Controller.Join def task_enablement(task_data) do case get_tokens(task_data) do diff --git a/lib/workflow_metal/controller/join/none.ex b/lib/workflow_metal/controller/join/none.ex index 27af727..c01f7d5 100644 --- a/lib/workflow_metal/controller/join/none.ex +++ b/lib/workflow_metal/controller/join/none.ex @@ -5,10 +5,10 @@ defmodule WorkflowMetal.Controller.Join.None do There is only one branch of the transition. """ - alias WorkflowMetal.Storage.Schema - @behaviour WorkflowMetal.Controller.Join + alias WorkflowMetal.Storage.Schema + @impl WorkflowMetal.Controller.Join def task_enablement(task_data) do case get_token(task_data) do @@ -29,8 +29,7 @@ defmodule WorkflowMetal.Controller.Join.None do token_table: token_table } = task_data - {:ok, [%Schema.Place{id: place_id}]} = - WorkflowMetal.Storage.fetch_places(application, transition_schema.id, :in) + {:ok, [%Schema.Place{id: place_id}]} = WorkflowMetal.Storage.fetch_places(application, transition_schema.id, :in) match_spec = [ { @@ -44,7 +43,7 @@ defmodule WorkflowMetal.Controller.Join.None do [token_id | _rest] -> {:ok, [token_id]} - _ -> + _other -> {:error, :task_not_enabled} end end diff --git a/lib/workflow_metal/controller/split/and.ex b/lib/workflow_metal/controller/split/and.ex index 2df0d5f..26b6920 100644 --- a/lib/workflow_metal/controller/split/and.ex +++ b/lib/workflow_metal/controller/split/and.ex @@ -1,10 +1,10 @@ defmodule WorkflowMetal.Controller.Split.And do @moduledoc false - alias WorkflowMetal.Storage.Schema - @behaviour WorkflowMetal.Controller.Split + alias WorkflowMetal.Storage.Schema + @impl true def issue_tokens(task_data, token_payload) do %{ diff --git a/lib/workflow_metal/controller/split/none.ex b/lib/workflow_metal/controller/split/none.ex index ecbb0c1..a23230b 100644 --- a/lib/workflow_metal/controller/split/none.ex +++ b/lib/workflow_metal/controller/split/none.ex @@ -1,10 +1,10 @@ defmodule WorkflowMetal.Controller.Split.None do @moduledoc false - alias WorkflowMetal.Storage.Schema - @behaviour WorkflowMetal.Controller.Split + alias WorkflowMetal.Storage.Schema + @impl true def issue_tokens(task_data, token_payload) do %{ diff --git a/lib/workflow_metal/executor.ex b/lib/workflow_metal/executor.ex index 68e1ab5..7bd74ca 100644 --- a/lib/workflow_metal/executor.ex +++ b/lib/workflow_metal/executor.ex @@ -79,12 +79,12 @@ defmodule WorkflowMetal.Executor do application = Keyword.get(opts, :application) quote do + @behaviour WorkflowMetal.Executor + alias WorkflowMetal.Storage.Schema @application unquote(application) - @behaviour WorkflowMetal.Executor - @before_compile unquote(__MODULE__) @impl WorkflowMetal.Executor diff --git a/lib/workflow_metal/storage.ex b/lib/workflow_metal/storage.ex index 848d9ea..5266de9 100644 --- a/lib/workflow_metal/storage.ex +++ b/lib/workflow_metal/storage.ex @@ -1,11 +1,11 @@ defmodule WorkflowMetal.Storage do - alias WorkflowMetal.Application - alias WorkflowMetal.Storage.Adapter - @moduledoc """ Use the storage configured for a WorkflowMetal application. """ + alias WorkflowMetal.Application + alias WorkflowMetal.Storage.Adapter + @type application :: WorkflowMetal.Application.t() @type workflow_id :: WorkflowMetal.Storage.Schema.Workflow.id() diff --git a/lib/workflow_metal/storage/adapters/in_memory.ex b/lib/workflow_metal/storage/adapters/in_memory.ex index 1caba57..76e80b9 100644 --- a/lib/workflow_metal/storage/adapters/in_memory.ex +++ b/lib/workflow_metal/storage/adapters/in_memory.ex @@ -28,14 +28,13 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do {workitem_id, workitem_schema, {workflow_id, case_id, task_id}} """ - alias WorkflowMetal.Utils.ETS, as: ETSUtil - - alias WorkflowMetal.Storage.Schema - @behaviour WorkflowMetal.Storage.Adapter use GenServer + alias WorkflowMetal.Storage.Schema + alias WorkflowMetal.Utils.ETS, as: ETSUtil + defmodule State do @moduledoc false @@ -338,33 +337,21 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:insert_workflow, workflow_schema, params}, - _from, - %State{} = state - ) do + def handle_call({:insert_workflow, workflow_schema, params}, _from, %State{} = state) do {:ok, workflow_schema} = persist_workflow(workflow_schema, state, params) {:reply, {:ok, workflow_schema}, state} end @impl GenServer - def handle_call( - {:fetch_workflow, workflow_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_workflow, workflow_id}, _from, %State{} = state) do reply = find_workflow(workflow_id, state) {:reply, reply, state} end @impl GenServer - def handle_call( - {:delete_workflow, workflow_id}, - _from, - %State{} = state - ) do + def handle_call({:delete_workflow, workflow_id}, _from, %State{} = state) do reply = with({:ok, workflow_schema} <- find_workflow(workflow_id, state)) do :workflow @@ -378,11 +365,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_arcs, {:transition, transition_id}, arc_direction}, - _from, - %State{} = state - ) do + def handle_call({:fetch_arcs, {:transition, transition_id}, arc_direction}, _from, %State{} = state) do arc_direction = reversed_arc_direction(arc_direction) arcs = @@ -396,11 +379,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_edge_places, workflow_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_edge_places, workflow_id}, _from, %State{} = state) do reply = with( {:ok, start_place} <- find_edge_place(workflow_id, :start, state), @@ -413,11 +392,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_places, transition_id, arc_direction}, - _from, - %State{} = state - ) do + def handle_call({:fetch_places, transition_id, arc_direction}, _from, %State{} = state) do direction = reversed_arc_direction(arc_direction) reply = @@ -439,22 +414,14 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_transition, transition_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_transition, transition_id}, _from, %State{} = state) do reply = find_transition(transition_id, state) {:reply, reply, state} end @impl GenServer - def handle_call( - {:fetch_transitions, place_id, arc_direction}, - _from, - %State{} = state - ) do + def handle_call({:fetch_transitions, place_id, arc_direction}, _from, %State{} = state) do reply = :arc |> get_table(state) @@ -474,11 +441,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:insert_case, case_schema}, - _from, - %State{} = state - ) do + def handle_call({:insert_case, case_schema}, _from, %State{} = state) do case_schema = %{case_schema | id: make_id()} reply = persist_case(case_schema, state) @@ -486,22 +449,14 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_case, case_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_case, case_id}, _from, %State{} = state) do reply = find_case(case_id, state) {:reply, reply, state} end @impl GenServer - def handle_call( - {:update_case, case_id, params}, - _from, - %State{} = state - ) do + def handle_call({:update_case, case_id, params}, _from, %State{} = state) do reply = with({:ok, case_schema} <- find_case(case_id, state)) do do_update_case(case_schema, params, state) @@ -511,11 +466,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:insert_task, task_schema}, - _from, - %State{} = state - ) do + def handle_call({:insert_task, task_schema}, _from, %State{} = state) do task_schema = %{task_schema | id: make_id()} reply = persist_task(task_schema, state) @@ -523,33 +474,21 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_task, task_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_task, task_id}, _from, %State{} = state) do reply = find_task(task_id, state) {:reply, reply, state} end @impl GenServer - def handle_call( - {:fetch_tasks, case_id, options}, - _from, - %State{} = state - ) do + def handle_call({:fetch_tasks, case_id, options}, _from, %State{} = state) do reply = do_fetch_tasks(case_id, options, state) {:reply, reply, state} end @impl GenServer - def handle_call( - {:update_task, task_id, params}, - _from, - %State{} = state - ) do + def handle_call({:update_task, task_id, params}, _from, %State{} = state) do case find_task(task_id, state) do {:ok, task_schema} -> task_schema = struct(task_schema, params) @@ -564,11 +503,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:issue_token, token_schema}, - _from, - %State{} = state - ) do + def handle_call({:issue_token, token_schema}, _from, %State{} = state) do token_schema = %{token_schema | id: make_id()} {:ok, token_schema} = upsert_token(token_schema, state) @@ -576,11 +511,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:lock_tokens, token_ids, locked_by_task_id}, - _from, - %State{} = state - ) do + def handle_call({:lock_tokens, token_ids, locked_by_task_id}, _from, %State{} = state) do tokens = find_tokens(token_ids, state) reply = do_lock_tokens(tokens, locked_by_task_id, state) @@ -589,11 +520,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:unlock_tokens, token_ids}, - _from, - %State{} = state - ) do + def handle_call({:unlock_tokens, token_ids}, _from, %State{} = state) do tokens = token_ids |> find_tokens(state) @@ -609,11 +536,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:consume_tokens, token_ids, consumed_by_task_id}, - _from, - %State{} = state - ) do + def handle_call({:consume_tokens, token_ids, consumed_by_task_id}, _from, %State{} = state) do tokens = token_ids |> find_tokens(state) @@ -629,11 +552,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_unconsumed_tokens, case_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_unconsumed_tokens, case_id}, _from, %State{} = state) do tokens = :token |> get_table(state) @@ -649,22 +568,14 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_tokens, token_ids}, - _from, - %State{} = state - ) do + def handle_call({:fetch_tokens, token_ids}, _from, %State{} = state) do tokens = find_tokens(token_ids, state) {:reply, {:ok, tokens}, state} end @impl GenServer - def handle_call( - {:insert_workitem, workitem_schema}, - _from, - %State{} = state - ) do + def handle_call({:insert_workitem, workitem_schema}, _from, %State{} = state) do workitem_schema = %{workitem_schema | id: make_id()} reply = persist_workitem(workitem_schema, state) @@ -672,22 +583,14 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:fetch_workitem, workitem_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_workitem, workitem_id}, _from, %State{} = state) do reply = find_workitem(workitem_id, state) {:reply, reply, state} end @impl GenServer - def handle_call( - {:fetch_workitems, task_id}, - _from, - %State{} = state - ) do + def handle_call({:fetch_workitems, task_id}, _from, %State{} = state) do workitems = :workitem |> get_table(state) @@ -703,11 +606,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end @impl GenServer - def handle_call( - {:update_workitem, workitem_id, params}, - _from, - %State{} = state - ) do + def handle_call({:update_workitem, workitem_id, params}, _from, %State{} = state) do reply = with({:ok, workitem_schema} <- find_workitem(workitem_id, state)) do workitem_schema = struct(workitem_schema, params) @@ -819,7 +718,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end defp persist_places(places_schema, %State{} = state) do - Enum.into(places_schema, %{}, fn place_params -> + Map.new(places_schema, fn place_params -> {:ok, place_schema} = persist_place(place_params, state) {place_params.id, place_schema} @@ -852,7 +751,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end defp persist_transitions(transitions_schema, %State{} = state) do - Enum.into(transitions_schema, %{}, fn transition_schema -> + Map.new(transitions_schema, fn transition_schema -> {:ok, transition_schema} = persist_transition(transition_schema, state) {transition_schema.id, transition_schema} @@ -915,11 +814,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do end end - defp do_update_case( - %Schema.Case{} = case_schema, - %{} = params, - %State{} = state - ) do + defp do_update_case(%Schema.Case{} = case_schema, %{} = params, %State{} = state) do case_table = get_table(:case, state) case_schema = struct(case_schema, params) @@ -1111,8 +1006,7 @@ defmodule WorkflowMetal.Storage.Adapters.InMemory do Map.fetch!(state, table_name) end - defp storage_name(adapter_meta) when is_map(adapter_meta), - do: Map.get(adapter_meta, :name) + defp storage_name(adapter_meta) when is_map(adapter_meta), do: Map.get(adapter_meta, :name) defp make_id, do: :erlang.unique_integer([:positive, :monotonic]) diff --git a/lib/workflow_metal/storage/schema/case.ex b/lib/workflow_metal/storage/schema/case.ex index e82c3c5..19252ee 100644 --- a/lib/workflow_metal/storage/schema/case.ex +++ b/lib/workflow_metal/storage/schema/case.ex @@ -9,10 +9,11 @@ defmodule WorkflowMetal.Storage.Schema.Case do use TypedStruct - @type id :: term() - @type state :: :created | :active | :terminated | :finished + # credo:disable-for-next-line JetCredo.Checks.ExplicitAnyType + @type id() :: term() + @type state() :: :created | :active | :terminated | :finished - @type workflow_id :: WorkflowMetal.Storage.Schema.Workflow.id() + @type workflow_id() :: WorkflowMetal.Storage.Schema.Workflow.id() typedstruct enforce: true do field :id, id(), enforce: false diff --git a/lib/workflow_metal/task/supervisor.ex b/lib/workflow_metal/task/supervisor.ex index 3f414d3..c0ed56b 100644 --- a/lib/workflow_metal/task/supervisor.ex +++ b/lib/workflow_metal/task/supervisor.ex @@ -6,9 +6,7 @@ defmodule WorkflowMetal.Task.Supervisor do use DynamicSupervisor alias WorkflowMetal.Application.WorkflowsSupervisor - alias WorkflowMetal.Registration - alias WorkflowMetal.Storage.Schema @type application :: WorkflowMetal.Application.t() diff --git a/lib/workflow_metal/workitem/supervisor.ex b/lib/workflow_metal/workitem/supervisor.ex index 6df4993..b6b2092 100644 --- a/lib/workflow_metal/workitem/supervisor.ex +++ b/lib/workflow_metal/workitem/supervisor.ex @@ -6,9 +6,7 @@ defmodule WorkflowMetal.Workitem.Supervisor do use DynamicSupervisor alias WorkflowMetal.Application.WorkflowsSupervisor - alias WorkflowMetal.Registration - alias WorkflowMetal.Storage.Schema @type application :: WorkflowMetal.Application.t() @@ -49,9 +47,7 @@ defmodule WorkflowMetal.Workitem.Supervisor do WorkflowMetal.Registration.Adapter.on_start_child() | {:error, :workitem_not_found} def open_workitem(application, %Schema.Workitem{} = workitem_schema) do - with( - {:ok, _} <- WorkflowsSupervisor.open_workflow(application, workitem_schema.workflow_id) - ) do + with({:ok, _} <- WorkflowsSupervisor.open_workflow(application, workitem_schema.workflow_id)) do workitem_supervisor = via_name(application, workitem_schema.workflow_id) workitem_spec = { @@ -69,9 +65,7 @@ defmodule WorkflowMetal.Workitem.Supervisor do end def open_workitem(application, workitem_id) do - with( - {:ok, workitem_schema} <- WorkflowMetal.Storage.fetch_workitem(application, workitem_id) - ) do + with({:ok, workitem_schema} <- WorkflowMetal.Storage.fetch_workitem(application, workitem_id)) do open_workitem(application, workitem_schema) end end diff --git a/mix.exs b/mix.exs index f1f3ff4..e3da2a8 100644 --- a/mix.exs +++ b/mix.exs @@ -26,11 +26,11 @@ defmodule WorkflowMetal.MixProject do ] end - defp description() do + defp description do "Workflow engine based on PetriNet" end - defp package() do + defp package do [ licenses: ["MIT"], links: %{"GitHub" => "https://github.com/Byzanteam/workflow_metal"} @@ -44,16 +44,12 @@ defmodule WorkflowMetal.MixProject do {:typed_struct, "~> 0.3.0"}, {:credo, "~> 1.6", only: [:dev, :test], runtime: false}, {:jet_credo, [github: "Byzanteam/jet_credo", only: [:dev, :test], runtime: false]}, + {:styler, "~> 0.7", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.0", only: [:dev], runtime: false} ] end - defp elixirc_paths(:test), - do: [ - "lib", - "test/support", - "test/helpers" - ] + defp elixirc_paths(:test), do: ["lib", "test/support", "test/helpers"] defp elixirc_paths(_), do: ["lib"] diff --git a/mix.lock b/mix.lock index 66dc182..d23d257 100644 --- a/mix.lock +++ b/mix.lock @@ -14,5 +14,6 @@ "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.2", "b99ca56bbce410e9d5ee4f9155a212e942e224e259c7ebbf8f2c86ac21d4fa3c", [:mix], [], "hexpm", "98d51bd64d5f6a2a9c6bb7586ee8129e27dfaab1140b5a4753f24dac0ba27d2f"}, + "styler": {:hex, :styler, "0.7.12", "2ef9014ff6fa2d7fc728f86436ca2f8ff88078f76d4e099dae5a658a90d8e12a", [:mix], [], "hexpm", "9b309b7c02b302118a471b99a65e184f79b0a3b7803f970eef681d5f1bdbe472"}, "typed_struct": {:hex, :typed_struct, "0.3.0", "939789e3c1dca39d7170c87f729127469d1315dcf99fee8e152bb774b17e7ff7", [:mix], [], "hexpm", "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d"}, } diff --git a/test/support/in_memory_storage_case.ex b/test/support/in_memory_storage_case.ex index 1967993..101c237 100644 --- a/test/support/in_memory_storage_case.ex +++ b/test/support/in_memory_storage_case.ex @@ -7,6 +7,8 @@ defmodule WorkflowMetal.Support.InMemoryStorageCase do using do quote location: :keep do + import unquote(__MODULE__) + alias WorkflowMetal.Storage.Schema defmodule DummyApplication do @@ -16,8 +18,6 @@ defmodule WorkflowMetal.Support.InMemoryStorageCase do storage: WorkflowMetal.Storage.Adapters.InMemory end - import unquote(__MODULE__) - setup_all do start_supervised!(DummyApplication) @@ -27,8 +27,7 @@ defmodule WorkflowMetal.Support.InMemoryStorageCase do end def generate_genesis_token(application, workflow_schema, case_schema) do - {:ok, {start_place, _end_place}} = - WorkflowMetal.Storage.fetch_edge_places(application, workflow_schema.id) + {:ok, {start_place, _end_place}} = WorkflowMetal.Storage.fetch_edge_places(application, workflow_schema.id) genesis_token_schema = struct( diff --git a/test/support/workflows/sequential_routing.ex b/test/support/workflows/sequential_routing.ex index e3fd349..291648f 100644 --- a/test/support/workflows/sequential_routing.ex +++ b/test/support/workflows/sequential_routing.ex @@ -117,10 +117,7 @@ defmodule WorkflowMetal.Support.Workflows.SequentialRouting do end @doc false - def build_workflow_associations_params( - %Schema.Workflow{} = workflow_schema, - [first | rest] = nodes - ) do + def build_workflow_associations_params(%Schema.Workflow{} = workflow_schema, [first | rest] = nodes) do {_, arcs} = Enum.reduce(rest, {first, []}, fn %Schema.Place{} = to, {%Schema.Transition{} = from, arcs} -> diff --git a/test/workflow_metal/application/workflows_supervisor_test.exs b/test/workflow_metal/application/workflows_supervisor_test.exs index 156c73d..bcdf41f 100644 --- a/test/workflow_metal/application/workflows_supervisor_test.exs +++ b/test/workflow_metal/application/workflows_supervisor_test.exs @@ -1,14 +1,15 @@ defmodule WorkflowMetal.Application.WorkflowsSupervisorTest do use ExUnit.Case, async: true + alias WorkflowMetal.Application.WorkflowsSupervisor + alias WorkflowMetal.Support.Workflows.SequentialRouting + defmodule DummyApplication do + @moduledoc false use WorkflowMetal.Application, storage: WorkflowMetal.Storage.Adapters.InMemory end - alias WorkflowMetal.Application.WorkflowsSupervisor - alias WorkflowMetal.Support.Workflows.SequentialRouting - setup_all do start_supervised!(DummyApplication) @@ -17,8 +18,7 @@ defmodule WorkflowMetal.Application.WorkflowsSupervisorTest do describe ".open_workflow/2" do test "failed to open a non-existing workflow" do - assert {:error, :workflow_not_found} = - WorkflowsSupervisor.open_workflow(DummyApplication, 123) + assert {:error, :workflow_not_found} = WorkflowsSupervisor.open_workflow(DummyApplication, 123) end test "open a sequential_routing workflow successfully" do diff --git a/test/workflow_metal/application_test.exs b/test/workflow_metal/application_test.exs index 6a53699..d03ba7b 100644 --- a/test/workflow_metal/application_test.exs +++ b/test/workflow_metal/application_test.exs @@ -1,19 +1,18 @@ defmodule WorkflowMetal.ApplicationTest do use ExUnit.Case, async: true + alias WorkflowMetal.Application.Config + defmodule DummyApplication do + @moduledoc false use WorkflowMetal.Application, name: __MODULE__.TestApplication, storage: WorkflowMetal.Storage.Adapters.InMemory end - alias WorkflowMetal.Application.Config - - alias DummyApplication.TestApplication - test "build an application" do - start_supervised(DummyApplication) + start_supervised!(DummyApplication) - assert Config.get(TestApplication, :registry) + assert Config.get(DummyApplication.TestApplication, :registry) end end diff --git a/test/workflow_metal/integrations/abandon_competitors_test.exs b/test/workflow_metal/integrations/abandon_competitors_test.exs index 943604b..aaf14b0 100644 --- a/test/workflow_metal/integrations/abandon_competitors_test.exs +++ b/test/workflow_metal/integrations/abandon_competitors_test.exs @@ -5,11 +5,8 @@ defmodule WorkflowMetal.Integrations.AbandonCompetitorsTest do import WorkflowMetal.Helpers.Wait alias WorkflowMetal.Case.Supervisor, as: CaseSupervisor - - alias WorkflowMetal.Support.Workflows.DeferredChoiceRouting.{ - ManualTransition, - SimpleTransition - } + alias WorkflowMetal.Support.Workflows.DeferredChoiceRouting.ManualTransition + alias WorkflowMetal.Support.Workflows.DeferredChoiceRouting.SimpleTransition setup do params = %{workflow_id: 1} @@ -90,7 +87,7 @@ defmodule WorkflowMetal.Integrations.AbandonCompetitorsTest do ^last -> :end - _ -> + _other -> :normal end diff --git a/test/workflow_metal/utils/ets_test.exs b/test/workflow_metal/utils/ets_test.exs index bfdcd63..a295830 100644 --- a/test/workflow_metal/utils/ets_test.exs +++ b/test/workflow_metal/utils/ets_test.exs @@ -1,4 +1,5 @@ defmodule WorkflowMetal.Utils.ETSTest do use ExUnit.Case, async: true + doctest WorkflowMetal.Utils.ETS end