View Source SplitClient.Sandbox (SplitClient v0.1.0)
Handles the orchestration of keeping treatment data isolated between concurrently running tests.
It assumes that the SplitClient calls from your Application code are
running in the same process as the test. If they are not, you will have
to explicitally allow
some other child process to access the
treatments data or make the test async: false
Link to this section Summary
Functions
Associate a process that is making SplitClient calls with a specific test's isolated Treatment data
Returns a specification to start this module under a supervisor.
Populate the test environment with split information that your application code depends on.
Change how treatment data is looked up based on whether
the test is async: false
or async: true
Associate a test process with a new Treatments server and data source server that will be isolated from all other tests
Teardown logic when a test is done
Link to this section Functions
Associate a process that is making SplitClient calls with a specific test's isolated Treatment data
examples
Examples
iex>SplitClient.Sandbox.allow(self(), Process.whereis(:foo))
:ok
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec create_splits(splits :: [map()]) :: :ok
Populate the test environment with split information that your application code depends on.
Your splits should come as a list of maps. Each map should have one key for the split_name which has as its value a map with the treatment information.
create_splits/1
must be run after SplitClient.Testing.setup_split_client/1
[
%{
"my_feature" => %{
treatment: "on",
keys: "mock_user_id",
traffic_type: "customer"
}
},
%{
"my_feature" => %{
treatment: "off",
traffic_type: "customer"
}
}
]
@spec get_treatment(key :: String.t(), split_name :: String.t(), options :: keyword()) :: SplitClient.Treatment.t()
Change how treatment data is looked up based on whether
the test is async: false
or async: true
setup_test_treatments(name \\ __MODULE__, test_pid, treatments_pid, data_source_pid)
View SourceAssociate a test process with a new Treatments server and data source server that will be isolated from all other tests
Teardown logic when a test is done