Skip to content

Commit

Permalink
Merge pull request #100 from mathiaHT/test/postgres_share_mode
Browse files Browse the repository at this point in the history
Add shared mode + explicit checkout of database for the tests
  • Loading branch information
MarcAntoine-Arnaud authored Mar 2, 2021
2 parents 120efd5 + 131b8c3 commit 03b1ecf
Show file tree
Hide file tree
Showing 41 changed files with 101 additions and 17 deletions.
12 changes: 8 additions & 4 deletions lib/step_flow/configuration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ defmodule StepFlow.Configuration do
def get_var_value(module, key, default \\ nil) do
conf_module = Application.get_env(:step_flow, module)

case Keyword.get(conf_module, key) do
{:system, variable} -> System.get_env(variable)
nil -> default
value -> value
if conf_module != nil do
case Keyword.get(conf_module, key) do
{:system, variable} -> System.get_env(variable)
nil -> default
value -> value
end
else
default
end
end

Expand Down
2 changes: 2 additions & 0 deletions test/amqp/progression_consumer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ defmodule StepFlow.Amqp.ProgressionConsumerTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/api/jobs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule StepFlow.Api.JobsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

test "GET /jobs" do
Expand Down
2 changes: 2 additions & 0 deletions test/api/root_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule StepFlow.Api.RootTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

test "GET /" do
Expand Down
2 changes: 2 additions & 0 deletions test/api/worker_definitions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ defmodule StepFlow.Api.WorkerDefinitionsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
for model <- [WorkerDefinition], do: StepFlow.Repo.delete_all(model)
:ok
end
Expand Down
2 changes: 2 additions & 0 deletions test/api/workflow_definitions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule StepFlow.Api.WorkflowDefinitionsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "workflow_definition" do
Expand Down
2 changes: 2 additions & 0 deletions test/api/workflow_events_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ defmodule StepFlow.Api.WorkflowEventsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "workflow_events" do
Expand Down
2 changes: 2 additions & 0 deletions test/api/workflows_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ defmodule StepFlow.Api.WorkflowsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{conn, _channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/metrics/workflow_collector_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ defmodule Prometheus.Metrics.WorkflowCollectorTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "workflows" do
Expand Down
4 changes: 3 additions & 1 deletion test/notifications/slack_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ defmodule StepFlow.Notifications.SlackTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

test "notify Slack channel" do
Expand Down
4 changes: 3 additions & 1 deletion test/notifications/webhook_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ defmodule StepFlow.Notifications.WebhookTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

test_with_server "notify HTTP endpoint" do
Expand Down
2 changes: 2 additions & 0 deletions test/progressions/progressions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule StepFlow.ProgressionsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@workflow %{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.ConditionalBranchedWorkflowSkippedAndVoidTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.ConditionalBranchedWorkflowSkippedBranchTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.ConditionalBranchedWorkflowTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/destination_filename_template_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.DestinationFilenameTemplateTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/destination_path_template_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.DestinationPathTemplateTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
4 changes: 3 additions & 1 deletion test/run_workflows/empty_workflow_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ defmodule StepFlow.RunWorkflows.EmptyWorkflowTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "workflows" do
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/multiple_first_step_workflow_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.MultipleFirstStepWorkflowTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/multiple_inputs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.MultipleInputsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/multiple_jobs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.MultipleJobsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/parallel_and_sequential_steps_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.ParallelSequentialStepsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/parallel_steps_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.ParallelStepsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/parallel_steps_with_notification_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.ParallelStepsWithNotificationTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/simple_workflow_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.SimpleWorkflowTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
4 changes: 3 additions & 1 deletion test/run_workflows/skipped_steps_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.RunWorkflows.SkippedStepsTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "workflows" do
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/source_paths_template_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.SourcePathsTemplateTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
4 changes: 3 additions & 1 deletion test/run_workflows/status_step_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.RunWorkflows.StatusStepTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "workflows" do
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/template_with_special_params_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.TemplateWithSpecialParamsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/run_workflows/two_steps_workflow_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule StepFlow.RunWorkflows.TwoStepsWorkflowTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
{_conn, channel} = StepFlow.HelpersTest.get_amqp_connection()

on_exit(fn ->
Expand Down
2 changes: 2 additions & 0 deletions test/step/launch_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ defmodule StepFlow.LaunchTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "launch_test" do
Expand Down
4 changes: 3 additions & 1 deletion test/views/artifact_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.ArtifactViewTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@workflow %{
Expand Down
4 changes: 3 additions & 1 deletion test/views/job_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.JobViewTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@workflow %{
Expand Down
4 changes: 3 additions & 1 deletion test/views/progressions_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.ProgressionsViewTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@workflow %{
Expand Down
4 changes: 3 additions & 1 deletion test/views/right_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.RightViewTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@workflow %{
Expand Down
4 changes: 3 additions & 1 deletion test/views/status_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ defmodule StepFlow.StatusViewTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@workflow %{
Expand Down
4 changes: 3 additions & 1 deletion test/views/worker_definition_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.WorkerDefinitionViewTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@worker_definition %{
Expand Down
4 changes: 3 additions & 1 deletion test/views/workflow_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ defmodule StepFlow.WorkflowViewTest do

setup do
# Explicitly get a connection before each test
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

@workflow %{
Expand Down
2 changes: 2 additions & 0 deletions test/worker_definitions/worker_definitions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ defmodule StepFlow.WorkerDefinitionsTest do
setup do
# Explicitly get a connection before each test
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
for model <- [WorkerDefinition], do: StepFlow.Repo.delete_all(model)
:ok
end
Expand Down
4 changes: 3 additions & 1 deletion test/workflow_definitions/workflow_definitions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ defmodule StepFlow.WorkflowDefinitionsTest do
doctest StepFlow.WorkflowDefinitions

setup do
Sandbox.checkout(StepFlow.Repo)
:ok = Sandbox.checkout(StepFlow.Repo)
# Setting the shared mode
Sandbox.mode(StepFlow.Repo, {:shared, self()})
end

describe "workflow_definitions" do
Expand Down
Loading

0 comments on commit 03b1ecf

Please sign in to comment.