Skip to content

Commit b437754

Browse files
committed
Introduce ScriptRunnerBehaviour for use in CommandLine module
1 parent 1aba2eb commit b437754

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/script_runner.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
defmodule ElixirScript.ScriptRunnerBehaviour do
2+
@callback run(script :: String.t(), opts :: Keyword.t()) :: any()
3+
end
4+
15
defmodule ElixirScript.ScriptRunner do
26
@moduledoc """
37
Executes dynamic Elixir script content, allowing for the execution of arbitrary code snippets.
48
"""
9+
@behaviour ElixirScript.ScriptRunnerBehaviour
10+
511
alias ElixirScript.Context
612

13+
@impl ElixirScript.ScriptRunnerBehaviour
714
def run(script, opts \\ []) do
815
token = Keyword.get(opts, :github_token)
916

test/test_helper.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
Mox.defmock(SystemEnvMock, for: ElixirScript.Behaviours.SystemEnvBehaviour)
22
Application.put_env(:context, :system_env, SystemEnvMock)
33

4+
# # #
5+
46
Mox.defmock(TentacatMock.ClientMock,
57
for: ElixirScript.Behaviours.TentacatBehaviour.ClientBehaviour
68
)
79

810
Application.put_env(:script_runner, :tentacat_client, TentacatMock.ClientMock)
911

12+
# # #
13+
14+
Mox.defmock(ElixirScript.ScriptRunnerMock, for: ElixirScript.ScriptRunnerBehaviour)
15+
Application.put_env(:command_line, :script_runner, ElixirScript.ScriptRunnerMock)
16+
17+
# # #
18+
1019
ExUnit.start()

0 commit comments

Comments
 (0)