Skip to content

Commit

Permalink
Update tests for new Supervisior spec options in Elixir 15
Browse files Browse the repository at this point in the history
  • Loading branch information
tompave committed Jul 22, 2023
1 parent d316a8a commit bca25e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/fun_with_flags/supervisor_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule FunWithFlags.SupervisorTest do
use FunWithFlags.TestCase, async: false
import FunWithFlags.TestUtils

alias FunWithFlags.Config

Expand All @@ -20,7 +21,7 @@ defmodule FunWithFlags.SupervisorTest do
expected = {
:ok,
{
%{intensity: 3, period: 5, strategy: :one_for_one},
expected_supervisor_spec(),
[
%{
id: FunWithFlags.Store.Cache,
Expand Down Expand Up @@ -63,7 +64,7 @@ defmodule FunWithFlags.SupervisorTest do
expected = {
:ok,
{
%{intensity: 3, period: 5, strategy: :one_for_one},
expected_supervisor_spec(),
[
%{
id: FunWithFlags.Store.Cache,
Expand Down Expand Up @@ -104,7 +105,7 @@ defmodule FunWithFlags.SupervisorTest do
expected = {
:ok,
{
%{intensity: 3, period: 5, strategy: :one_for_one},
expected_supervisor_spec(),
[
%{
id: FunWithFlags.Store.Cache,
Expand Down Expand Up @@ -150,7 +151,7 @@ defmodule FunWithFlags.SupervisorTest do
expected = {
:ok,
{
%{intensity: 3, period: 5, strategy: :one_for_one},
expected_supervisor_spec(),
[
%{
id: Redix,
Expand Down Expand Up @@ -179,7 +180,7 @@ defmodule FunWithFlags.SupervisorTest do
expected = {
:ok,
{
%{intensity: 3, period: 5, strategy: :one_for_one},
expected_supervisor_spec(),
[
%{
id: Redix,
Expand Down Expand Up @@ -208,12 +209,20 @@ defmodule FunWithFlags.SupervisorTest do
expected = {
:ok,
{
%{intensity: 3, period: 5, strategy: :one_for_one},
expected_supervisor_spec(),
[]
}
}

assert ^expected = FunWithFlags.Supervisor.init(nil)
end
end

defp expected_supervisor_spec do
if on_elixir_15?() do
%{intensity: 3, period: 5, strategy: :one_for_one, auto_shutdown: :never}
else
%{intensity: 3, period: 5, strategy: :one_for_one}
end
end
end
4 changes: 4 additions & 0 deletions test/support/test_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ defmodule FunWithFlags.TestUtils do
def reset_app_env_to_default_redis_config do
configure_redis_with([database: 5])
end

def on_elixir_15? do
Version.match?(System.version, ">= 1.15.0")
end
end

0 comments on commit bca25e6

Please sign in to comment.