-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'disabled-flags-should-have-disabled-variants' into 'main'
Disabled flags should not produce an active variant See merge request afontaine/unleash_ex!20
- Loading branch information
Showing
3 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
defmodule Unleash.VariantTest do | ||
use ExUnit.Case | ||
|
||
setup :start_repo | ||
|
||
test "return a disabled variant if the flag is disabled" do | ||
assert %{ | ||
enabled: false, | ||
name: "disabled", | ||
payload: %{} | ||
} == Unleash.get_variant(:disabled_variant) | ||
end | ||
|
||
defp start_repo(_) do | ||
stop_supervised(Unleash.Repo) | ||
|
||
state = Unleash.Features.from_map!(state()) | ||
|
||
{:ok, _pid} = start_supervised({Unleash.Repo, state}) | ||
:ok | ||
end | ||
|
||
defp state, | ||
do: %{ | ||
"version" => 1, | ||
"features" => [ | ||
%{ | ||
"name" => "disabled_variant", | ||
"description" => "variant with enabled set to false", | ||
"enabled" => false, | ||
"strategies" => [ | ||
%{ | ||
"name" => "default", | ||
"parameters" => %{} | ||
} | ||
], | ||
"variants" => [ | ||
%{ | ||
"name" => "variant1", | ||
"weight" => 100, | ||
"payload" => %{"type" => "string", "value" => "val1"} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters