Documentation
¶
Overview ¶
Package optimizelytest //
Package optimizelytest //
Package optimizelytest //
Index ¶
- Variables
- type TestClient
- func (t *TestClient) AddDisabledFeatureRollout(f entities.Feature)
- func (t *TestClient) AddEvent(e entities.Event)
- func (t *TestClient) AddExperiment(experimentKey string, variations []entities.Variation)
- func (t TestClient) AddExperimentWithVariations(experimentKey string, variationKeys ...string)
- func (t TestClient) AddFeature(f entities.Feature)
- func (t *TestClient) AddFeatureRollout(f entities.Feature)
- func (t *TestClient) AddFeatureTest(f entities.Feature)
- func (t *TestClient) AddFeatureTestWithCustomVariableValue(feature entities.Feature, variable entities.Variable, customValue string)
- func (t *TestClient) AddFlagVariation(f entities.Feature, v entities.Variation)
- func (t *TestClient) GetProcessedEvents() []event.UserEvent
- type TestEventProcessor
- type TestProjectConfig
- func (c *TestProjectConfig) AddDisabledFeatureRollout(f entities.Feature) *TestProjectConfig
- func (c *TestProjectConfig) AddEvent(e entities.Event) *TestProjectConfig
- func (c *TestProjectConfig) AddExperiment(experimentKey string, variations []entities.Variation)
- func (c *TestProjectConfig) AddFeature(f entities.Feature) *TestProjectConfig
- func (c *TestProjectConfig) AddFeatureRollout(f entities.Feature) *TestProjectConfig
- func (c *TestProjectConfig) AddFeatureTest(f entities.Feature) *TestProjectConfig
- func (c *TestProjectConfig) AddFeatureTestWithCustomVariableValue(feature entities.Feature, variable entities.Variable, customValue string) *TestProjectConfig
- func (c *TestProjectConfig) AddFlagVariation(f entities.Feature, v entities.Variation)
- func (c *TestProjectConfig) AddMultiVariationABTest(experimentKey, variationAKey, variationBKey string) *TestProjectConfig
- func (c *TestProjectConfig) AddMultiVariationFeatureTest(f entities.Feature, disabledVariationKey, enabledVariationKey string) *TestProjectConfig
- func (c *TestProjectConfig) ConvertVariation(v entities.Variation) optlyconfig.OptimizelyVariation
- func (c *TestProjectConfig) CreateVariation(varKey string) entities.Variation
- func (c *TestProjectConfig) GetAccountID() string
- func (c *TestProjectConfig) GetAnonymizeIP() bool
- func (c *TestProjectConfig) GetAttributeByKey(key string) (entities.Attribute, error)
- func (c *TestProjectConfig) GetAttributeID(key string) string
- func (c *TestProjectConfig) GetAttributes() (attributeList []entities.Attribute)
- func (c *TestProjectConfig) GetAudienceByID(audienceID string) (entities.Audience, error)
- func (c *TestProjectConfig) GetAudienceList() (audienceList []entities.Audience)
- func (c *TestProjectConfig) GetAudienceMap() map[string]entities.Audience
- func (c *TestProjectConfig) GetBotFiltering() bool
- func (c *TestProjectConfig) GetDatafile() string
- func (c *TestProjectConfig) GetEnvironmentKey() string
- func (c *TestProjectConfig) GetEventByKey(eventKey string) (entities.Event, error)
- func (c *TestProjectConfig) GetEvents() (eventList []entities.Event)
- func (c *TestProjectConfig) GetExperimentByKey(experimentKey string) (entities.Experiment, error)
- func (c *TestProjectConfig) GetExperimentList() (experimentList []entities.Experiment)
- func (c *TestProjectConfig) GetFeatureByKey(featureKey string) (entities.Feature, error)
- func (c *TestProjectConfig) GetFeatureList() (featureList []entities.Feature)
- func (c *TestProjectConfig) GetFlagVariationsMap() map[string][]entities.Variation
- func (c *TestProjectConfig) GetGroupByID(groupID string) (entities.Group, error)
- func (c *TestProjectConfig) GetProjectID() string
- func (c *TestProjectConfig) GetRevision() string
- func (c *TestProjectConfig) GetRolloutList() (rolloutList []entities.Rollout)
- func (c *TestProjectConfig) GetSdkKey() string
- func (c *TestProjectConfig) GetVariableByKey(featureKey, variableKey string) (entities.Variable, error)
- func (c *TestProjectConfig) SendFlagDecisions() bool
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented indicates that the error was returned since the functionality was not implemented
Functions ¶
This section is empty.
Types ¶
type TestClient ¶
type TestClient struct {
EventProcessor *TestEventProcessor
ProjectConfig *TestProjectConfig
OptimizelyClient *client.OptimizelyClient
ForcedVariations *decision.MapExperimentOverridesStore
}
TestClient encapsulates both the ProjectConfig interface and the OptimizelyClient
func NewClient ¶
func NewClient() *TestClient
NewClient provides an instance of OptimizelyClient backed by a TestProjectConfig
func (*TestClient) AddDisabledFeatureRollout ¶
func (t *TestClient) AddDisabledFeatureRollout(f entities.Feature)
AddDisabledFeatureRollout is a helper method for creating a disabled rollout in the ProjectConfig to facilitate testing.
func (*TestClient) AddEvent ¶
func (t *TestClient) AddEvent(e entities.Event)
AddEvent is a helper method for adding events to the ProjectConfig to facilitate testing.
func (*TestClient) AddExperiment ¶
func (t *TestClient) AddExperiment(experimentKey string, variations []entities.Variation)
AddExperiment is a helper method for creating experiments in the ProjectConfig to facilitate testing.
func (TestClient) AddExperimentWithVariations ¶
func (t TestClient) AddExperimentWithVariations(experimentKey string, variationKeys ...string)
AddExperimentWithVariations is a helper method for adding and experiment with N variations
func (TestClient) AddFeature ¶
func (t TestClient) AddFeature(f entities.Feature)
AddFeature is a helper method for adding features to the ProjectConfig to facilitate testing.
func (*TestClient) AddFeatureRollout ¶
func (t *TestClient) AddFeatureRollout(f entities.Feature)
AddFeatureRollout is a helper method for adding feature rollouts to the ProjectConfig to facilitate testing.
func (*TestClient) AddFeatureTest ¶
func (t *TestClient) AddFeatureTest(f entities.Feature)
AddFeatureTest is a helper method for adding feature rollouts to the ProjectConfig to facilitate testing.
func (*TestClient) AddFeatureTestWithCustomVariableValue ¶
func (t *TestClient) AddFeatureTestWithCustomVariableValue(feature entities.Feature, variable entities.Variable, customValue string)
AddFeatureTestWithCustomVariableValue is a helper method for creating a feature test with a custom variable value in the ProjectConfig to facilitate testing.
func (*TestClient) AddFlagVariation ¶
func (t *TestClient) AddFlagVariation(f entities.Feature, v entities.Variation)
AddFlagVariation is a helper method for adding flag variation to the ProjectConfig to facilitate testing.
func (*TestClient) GetProcessedEvents ¶
func (t *TestClient) GetProcessedEvents() []event.UserEvent
GetProcessedEvents returns the UserEvent objects sent to the event processor.
type TestEventProcessor ¶
type TestEventProcessor struct {
// contains filtered or unexported fields
}
TestEventProcessor implements an Optimizely Processor to aid in testing
func (*TestEventProcessor) GetEvents ¶
func (p *TestEventProcessor) GetEvents() []event.UserEvent
GetEvents returns a copy of the events received by the TestEventProcessor
func (*TestEventProcessor) OnEventDispatch ¶
func (p *TestEventProcessor) OnEventDispatch(callback func(logEvent event.LogEvent)) (int, error)
OnEventDispatch is a non-op notification action
func (*TestEventProcessor) ProcessEvent ¶
func (p *TestEventProcessor) ProcessEvent(e event.UserEvent) bool
ProcessEvent appends the events to a slice of UserEvents
func (*TestEventProcessor) RemoveOnEventDispatch ¶
func (p *TestEventProcessor) RemoveOnEventDispatch(id int) error
RemoveOnEventDispatch is a non-op notification action
type TestProjectConfig ¶
type TestProjectConfig struct {
Datafile string
AccountID string
ProjectID string
Revision string
ExperimentKeyToIDMap map[string]string
AudienceMap map[string]entities.Audience
AttributeMap map[string]entities.Attribute
EventMap map[string]entities.Event
AttributeKeyToIDMap map[string]string
ExperimentMap map[string]entities.Experiment
FeatureMap map[string]entities.Feature
GroupMap map[string]entities.Group
RolloutMap map[string]entities.Rollout
AnonymizeIP bool
BotFiltering bool
// contains filtered or unexported fields
}
TestProjectConfig is a project config backed by a datafile
func NewConfig ¶
func NewConfig() *TestProjectConfig
NewConfig initializes a new datafile from a json byte array using the default JSON datafile parser
func (*TestProjectConfig) AddDisabledFeatureRollout ¶
func (c *TestProjectConfig) AddDisabledFeatureRollout(f entities.Feature) *TestProjectConfig
AddDisabledFeatureRollout adds modeling of a disabled feature rollout (variation's FeatureEnabled is false)
func (*TestProjectConfig) AddEvent ¶
func (c *TestProjectConfig) AddEvent(e entities.Event) *TestProjectConfig
AddEvent adds the event to the EventMap
func (*TestProjectConfig) AddExperiment ¶
func (c *TestProjectConfig) AddExperiment(experimentKey string, variations []entities.Variation)
AddExperiment adds the experiment and the supporting entities to complete the experiment modeling
func (*TestProjectConfig) AddFeature ¶
func (c *TestProjectConfig) AddFeature(f entities.Feature) *TestProjectConfig
AddFeature adds the feature to the FeatureMap
func (*TestProjectConfig) AddFeatureRollout ¶
func (c *TestProjectConfig) AddFeatureRollout(f entities.Feature) *TestProjectConfig
AddFeatureRollout adds the feature and supporting entities to complete the rollout modeling
func (*TestProjectConfig) AddFeatureTest ¶
func (c *TestProjectConfig) AddFeatureTest(f entities.Feature) *TestProjectConfig
AddFeatureTest adds the feature and supporting entities to complete the feature test modeling
func (*TestProjectConfig) AddFeatureTestWithCustomVariableValue ¶
func (c *TestProjectConfig) AddFeatureTestWithCustomVariableValue(feature entities.Feature, variable entities.Variable, customValue string) *TestProjectConfig
AddFeatureTestWithCustomVariableValue adds modeling of a 1-variation feature test with a custom variable value
func (*TestProjectConfig) AddFlagVariation ¶
func (c *TestProjectConfig) AddFlagVariation(f entities.Feature, v entities.Variation)
AddFlagVariation Adds to map of all variations for each flag
func (*TestProjectConfig) AddMultiVariationABTest ¶
func (c *TestProjectConfig) AddMultiVariationABTest(experimentKey, variationAKey, variationBKey string) *TestProjectConfig
AddMultiVariationABTest adds an AB test with the following property: - Traffic allocation is 100% first variation, 0% second variation
func (*TestProjectConfig) AddMultiVariationFeatureTest ¶
func (c *TestProjectConfig) AddMultiVariationFeatureTest(f entities.Feature, disabledVariationKey, enabledVariationKey string) *TestProjectConfig
AddMultiVariationFeatureTest adds the feature and supporting entities to complete modeling of the following: - Feature test with two variations - Feature is disabled in first variation, enabled in second variation - Traffic allocation is 100% first variation, 0% second variation
func (*TestProjectConfig) ConvertVariation ¶
func (c *TestProjectConfig) ConvertVariation(v entities.Variation) optlyconfig.OptimizelyVariation
ConvertVariation converts entities variation to optimizely config variation
func (*TestProjectConfig) CreateVariation ¶
func (c *TestProjectConfig) CreateVariation(varKey string) entities.Variation
CreateVariation creates a variation with the given key and a generated ID
func (*TestProjectConfig) GetAccountID ¶
func (c *TestProjectConfig) GetAccountID() string
GetAccountID returns accountID
func (*TestProjectConfig) GetAnonymizeIP ¶
func (c *TestProjectConfig) GetAnonymizeIP() bool
GetAnonymizeIP returns anonymizeIP
func (*TestProjectConfig) GetAttributeByKey ¶
func (c *TestProjectConfig) GetAttributeByKey(key string) (entities.Attribute, error)
GetAttributeByKey returns the attribute with the given key
func (*TestProjectConfig) GetAttributeID ¶
func (c *TestProjectConfig) GetAttributeID(key string) string
GetAttributeID returns attributeID
func (*TestProjectConfig) GetAttributes ¶
func (c *TestProjectConfig) GetAttributes() (attributeList []entities.Attribute)
GetAttributes returns attributes
func (*TestProjectConfig) GetAudienceByID ¶
func (c *TestProjectConfig) GetAudienceByID(audienceID string) (entities.Audience, error)
GetAudienceByID returns the audience with the given ID
func (*TestProjectConfig) GetAudienceList ¶
func (c *TestProjectConfig) GetAudienceList() (audienceList []entities.Audience)
GetAudienceList returns an array of all the audiences
func (*TestProjectConfig) GetAudienceMap ¶
func (c *TestProjectConfig) GetAudienceMap() map[string]entities.Audience
GetAudienceMap returns the audience map
func (*TestProjectConfig) GetBotFiltering ¶
func (c *TestProjectConfig) GetBotFiltering() bool
GetBotFiltering returns GetBotFiltering
func (*TestProjectConfig) GetDatafile ¶
func (c *TestProjectConfig) GetDatafile() string
GetDatafile returns a string representation of the environment's datafile
func (*TestProjectConfig) GetEnvironmentKey ¶
func (c *TestProjectConfig) GetEnvironmentKey() string
GetEnvironmentKey returns current environment of the datafile.
func (*TestProjectConfig) GetEventByKey ¶
func (c *TestProjectConfig) GetEventByKey(eventKey string) (entities.Event, error)
GetEventByKey returns the event with the given key
func (*TestProjectConfig) GetEvents ¶
func (c *TestProjectConfig) GetEvents() (eventList []entities.Event)
GetEvents returns all events
func (*TestProjectConfig) GetExperimentByKey ¶
func (c *TestProjectConfig) GetExperimentByKey(experimentKey string) (entities.Experiment, error)
GetExperimentByKey returns the experiment with the given key
func (*TestProjectConfig) GetExperimentList ¶
func (c *TestProjectConfig) GetExperimentList() (experimentList []entities.Experiment)
GetExperimentList returns an array of all the experiments
func (*TestProjectConfig) GetFeatureByKey ¶
func (c *TestProjectConfig) GetFeatureByKey(featureKey string) (entities.Feature, error)
GetFeatureByKey returns the feature with the given key
func (*TestProjectConfig) GetFeatureList ¶
func (c *TestProjectConfig) GetFeatureList() (featureList []entities.Feature)
GetFeatureList returns an array of all the features
func (*TestProjectConfig) GetFlagVariationsMap ¶
func (c *TestProjectConfig) GetFlagVariationsMap() map[string][]entities.Variation
GetFlagVariationsMap returns map containing all variations for each flag
func (*TestProjectConfig) GetGroupByID ¶
func (c *TestProjectConfig) GetGroupByID(groupID string) (entities.Group, error)
GetGroupByID returns the group with the given ID
func (*TestProjectConfig) GetProjectID ¶
func (c *TestProjectConfig) GetProjectID() string
GetProjectID returns projectID
func (*TestProjectConfig) GetRevision ¶
func (c *TestProjectConfig) GetRevision() string
GetRevision returns revision
func (*TestProjectConfig) GetRolloutList ¶
func (c *TestProjectConfig) GetRolloutList() (rolloutList []entities.Rollout)
GetRolloutList returns an array of all the rollouts
func (*TestProjectConfig) GetSdkKey ¶
func (c *TestProjectConfig) GetSdkKey() string
GetSdkKey returns sdkKey for specific environment.
func (*TestProjectConfig) GetVariableByKey ¶
func (c *TestProjectConfig) GetVariableByKey(featureKey, variableKey string) (entities.Variable, error)
GetVariableByKey returns the featureVariable with the given key
func (*TestProjectConfig) SendFlagDecisions ¶
func (c *TestProjectConfig) SendFlagDecisions() bool
SendFlagDecisions returns the value of sendFlagDecisions