Documentation ¶
Overview ¶
Package sdktests contains the domain-specific SDK test logic.
Tests in this package use other packages as follows:
ldtest: the basic test scope framework
mockd: mock LaunchDarkly service components
servicedef: types used in communication with an SDK test service
testdata: test data file schemas and loader
Index ¶
- func EqualReason(reason ldreason.EvaluationReason) m.Matcher
- func EvalAllFlagsStateMap() m.MatcherTransform
- func EvalAllFlagsValueForKeyShouldEqual(key string, value ldvalue.Value) m.Matcher
- func EvalResponseReason() m.MatcherTransform
- func EvalResponseValue() m.MatcherTransform
- func EvalResponseVariation() m.MatcherTransform
- func EventHasKind(kind string) m.Matcher
- func HasAnyCreationDate() m.Matcher
- func HasContextKind(user lduser.User) m.Matcher
- func HasNoUserKeyProperty() m.Matcher
- func HasNoUserObject() m.Matcher
- func HasUserKeyProperty(key string) m.Matcher
- func HasUserObjectWithKey(key string) m.Matcher
- func Header(name string) m.MatcherTransform
- func IsAliasEvent() m.Matcher
- func IsCustomEvent() m.Matcher
- func IsCustomEventForEventKey(key string) m.Matcher
- func IsDebugEvent() m.Matcher
- func IsFeatureEvent() m.Matcher
- func IsIdentifyEvent() m.Matcher
- func IsIdentifyEventForUserKey(key string) m.Matcher
- func IsIndexEvent() m.Matcher
- func IsIndexEventForUserKey(key string) m.Matcher
- func IsSummaryEvent() m.Matcher
- func IsValidFeatureEventWithConditions(matchers ...m.Matcher) m.Matcher
- func IsValidSummaryEventWithFlags(keyValueMatchers ...m.KeyValueMatcher) m.Matcher
- func JSONPropertyKeysCanOnlyBe(keys ...string) m.Matcher
- func JSONPropertyNullOrAbsent(name string) m.Matcher
- func RunSDKTestSuite(harness *harness.TestHarness, filter ldtest.Filter, ...) ldtest.Results
- func SortedStrings() m.MatcherTransform
- func ValueIsPositiveNonZeroInteger() m.Matcher
- type BigSegmentStore
- func (b *BigSegmentStore) Configure(config *servicedef.SDKConfigParams) error
- func (b *BigSegmentStore) ExpectMetadataQuery(t *ldtest.T, timeout time.Duration)
- func (b *BigSegmentStore) ExpectNoMoreMetadataQueries(t *ldtest.T, timeout time.Duration)
- func (b *BigSegmentStore) GetMembershipQueries() []string
- func (b *BigSegmentStore) SetupGetMetadata(fn func() (ldtime.UnixMillisecondTime, error))
- func (b *BigSegmentStore) SetupGetUserMembership(fn func(userHash string) (map[string]bool, error))
- func (b *BigSegmentStore) SetupMemberships(t *ldtest.T, memberships map[string]map[string]bool)
- func (b *BigSegmentStore) SetupMetadataForStatus(status ldreason.BigSegmentsStatus)
- type CommonEvalParameterizedTestRunner
- type CommonEventTests
- func (c CommonEventTests) AliasEvents(t *ldtest.T)
- func (c CommonEventTests) BufferBehavior(t *ldtest.T)
- func (c CommonEventTests) CustomEvents(t *ldtest.T)
- func (c CommonEventTests) DisablingEvents(t *ldtest.T)
- func (c CommonEventTests) EventUsers(t *ldtest.T)
- func (c CommonEventTests) IdentifyEvents(t *ldtest.T)
- func (c CommonEventTests) RequestMethodAndHeaders(t *ldtest.T, headersMatcher m.Matcher)
- func (c CommonEventTests) RequestURLPath(t *ldtest.T, pathMatcher m.Matcher)
- func (c CommonEventTests) UniquePayloadIDs(t *ldtest.T)
- type CommonTagsTests
- type FlagFactory
- type FlagFactoryForValueTypes
- type MemoizingFlagFactory
- type SDKClient
- func (c *SDKClient) Close() error
- func (c *SDKClient) EvaluateAllFlags(t *ldtest.T, params servicedef.EvaluateAllFlagsParams) servicedef.EvaluateAllFlagsResponse
- func (c *SDKClient) EvaluateFlag(t *ldtest.T, params servicedef.EvaluateFlagParams) servicedef.EvaluateFlagResponse
- func (c *SDKClient) FlushEvents(t *ldtest.T)
- func (c *SDKClient) GetBigSegmentStoreStatus(t *ldtest.T) servicedef.BigSegmentStoreStatusResponse
- func (c *SDKClient) SendAliasEvent(t *ldtest.T, params servicedef.AliasEventParams)
- func (c *SDKClient) SendCustomEvent(t *ldtest.T, params servicedef.CustomEventParams)
- func (c *SDKClient) SendIdentifyEvent(t *ldtest.T, user lduser.User)
- type SDKConfigurer
- func WithClientSideConfig(clientSideConfig servicedef.SDKConfigClientSideParams) SDKConfigurer
- func WithConfig(config servicedef.SDKConfigParams) SDKConfigurer
- func WithCredential(credential string) SDKConfigurer
- func WithEventsConfig(eventsConfig servicedef.SDKConfigEventParams) SDKConfigurer
- func WithServiceEndpointsConfig(endpointsConfig servicedef.SDKConfigServiceEndpointsParams) SDKConfigurer
- func WithStreamingConfig(streamingConfig servicedef.SDKConfigStreamingParams) SDKConfigurer
- type SDKDataSource
- func (d *SDKDataSource) Configure(config *servicedef.SDKConfigParams) error
- func (d *SDKDataSource) Endpoint() *harness.MockEndpoint
- func (d *SDKDataSource) Handler() http.Handler
- func (d *SDKDataSource) PollingService() *mockld.PollingService
- func (d *SDKDataSource) StreamingService() *mockld.StreamingService
- type SDKDataSourceOption
- type SDKEventSink
- func (e *SDKEventSink) Configure(config *servicedef.SDKConfigParams) error
- func (e *SDKEventSink) Endpoint() *harness.MockEndpoint
- func (e *SDKEventSink) ExpectAnalyticsEvents(t require.TestingT, timeout time.Duration) mockld.Events
- func (e *SDKEventSink) ExpectNoAnalyticsEvents(t require.TestingT, timeout time.Duration)
- func (e *SDKEventSink) Service() *mockld.EventsService
- type SDKTestContext
- type UserFactory
- type ValueFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualReason ¶ added in v1.4.0
func EqualReason(reason ldreason.EvaluationReason) m.Matcher
EqualReason is a type-safe replacement for m.Equal(EvaluationReason) that also provides better failure output, by treating it as a JSON object-- since the default implementation of String() for EvaluationReason returns a shorter string that doesn't include every property.
func EvalAllFlagsStateMap ¶ added in v1.0.0
func EvalAllFlagsStateMap() m.MatcherTransform
func EvalAllFlagsValueForKeyShouldEqual ¶ added in v1.0.0
func EvalResponseReason ¶
func EvalResponseReason() m.MatcherTransform
func EvalResponseValue ¶
func EvalResponseValue() m.MatcherTransform
func EvalResponseVariation ¶
func EvalResponseVariation() m.MatcherTransform
func EventHasKind ¶
func HasAnyCreationDate ¶ added in v1.1.2
func HasNoUserKeyProperty ¶ added in v1.1.2
func HasNoUserObject ¶ added in v1.1.2
func HasUserKeyProperty ¶ added in v1.1.2
func HasUserObjectWithKey ¶ added in v1.1.2
func Header ¶ added in v1.6.0
func Header(name string) m.MatcherTransform
func IsAliasEvent ¶ added in v1.1.2
func IsCustomEvent ¶ added in v1.1.2
func IsCustomEventForEventKey ¶ added in v1.1.2
func IsDebugEvent ¶ added in v1.1.2
func IsFeatureEvent ¶ added in v1.1.2
func IsIdentifyEvent ¶ added in v1.1.2
func IsIdentifyEventForUserKey ¶ added in v1.1.2
func IsIndexEvent ¶ added in v1.1.2
func IsIndexEventForUserKey ¶ added in v1.1.2
func IsSummaryEvent ¶ added in v1.1.2
func IsValidFeatureEventWithConditions ¶ added in v1.1.2
func IsValidSummaryEventWithFlags ¶ added in v1.1.2
func IsValidSummaryEventWithFlags(keyValueMatchers ...m.KeyValueMatcher) m.Matcher
func JSONPropertyKeysCanOnlyBe ¶ added in v1.1.2
func JSONPropertyNullOrAbsent ¶ added in v1.1.2
func RunSDKTestSuite ¶ added in v1.6.0
func RunSDKTestSuite( harness *harness.TestHarness, filter ldtest.Filter, testLogger ldtest.TestLogger, ) ldtest.Results
func SortedStrings ¶ added in v1.1.2
func SortedStrings() m.MatcherTransform
func ValueIsPositiveNonZeroInteger ¶ added in v1.0.0
Types ¶
type BigSegmentStore ¶ added in v1.1.0
type BigSegmentStore struct {
// contains filtered or unexported fields
}
BigSegmentStore is a test fixture that provides callback endpoints for SDK clients to connect to, behaving like a Big Segment store for a simulated database.
func NewBigSegmentStore ¶ added in v1.1.0
func NewBigSegmentStore(t *ldtest.T, initialStatus ldreason.BigSegmentsStatus) *BigSegmentStore
NewBigSegmentStore creates a new BigSegmentStore with the specified initial status.
The object's lifecycle is tied to the test scope that created it; it will be automatically closed when this test scope exits. It can be reused by subtests until then. Debug output related to the data source will be attached to this test scope.
func (*BigSegmentStore) Configure ¶ added in v1.6.0
func (b *BigSegmentStore) Configure(config *servicedef.SDKConfigParams) error
Configure updates the SDK client configuration for NewSDKClient, causing the SDK to connect to the appropriate base URI for the big segments test fixture.
func (*BigSegmentStore) ExpectMetadataQuery ¶ added in v1.1.0
func (b *BigSegmentStore) ExpectMetadataQuery(t *ldtest.T, timeout time.Duration)
ExpectMetadataQuery blocks until the Big Segment store has received a metadata query.
func (*BigSegmentStore) ExpectNoMoreMetadataQueries ¶ added in v1.1.0
func (b *BigSegmentStore) ExpectNoMoreMetadataQueries(t *ldtest.T, timeout time.Duration)
ExpectNoMoreMetadataQueries causes a test failure if the Big Segment store receives a metadata query.
func (*BigSegmentStore) GetMembershipQueries ¶ added in v1.1.0
func (b *BigSegmentStore) GetMembershipQueries() []string
GetMembershipQueries returns the user hashes of all membership queries that have been received so far.
func (*BigSegmentStore) SetupGetMetadata ¶ added in v1.1.0
func (b *BigSegmentStore) SetupGetMetadata(fn func() (ldtime.UnixMillisecondTime, error))
SetupGetMetadata causes the specified function to be called whenever the SDK calls the "get metadata" method on the Big Segment store.
func (*BigSegmentStore) SetupGetUserMembership ¶ added in v1.1.0
func (b *BigSegmentStore) SetupGetUserMembership(fn func(userHash string) (map[string]bool, error))
SetupGetUserMembership causes the specified function to be called whenever the SDK calls the "get user membership" method on the Big Segment store.
func (*BigSegmentStore) SetupMemberships ¶ added in v1.1.0
SetupMemberships is a shortcut to call SetupGetUserMembership with appropriate logic for providing preconfigured results for each possible user hash. Any user hash whose key does not appear in the map will cause the test to fail.
func (*BigSegmentStore) SetupMetadataForStatus ¶ added in v1.1.0
func (b *BigSegmentStore) SetupMetadataForStatus(status ldreason.BigSegmentsStatus)
SetupMetadataForStatus is a shortcut to call SetupGetMetadata with appropriate logic for making the Big Segment store return a current time ("healthy" status), an old time ("stale" status), or an error ("store error" status).
type CommonEvalParameterizedTestRunner ¶ added in v1.6.0
type CommonEvalParameterizedTestRunner[SDKDataType mockld.SDKData] struct { SDKConfigurers func(testmodel.EvalTestSuite[SDKDataType]) []SDKConfigurer FilterSDKData func(SDKDataType) SDKDataType FilterExpectedReason func(ldreason.EvaluationReason) ldreason.EvaluationReason }
type CommonEventTests ¶ added in v1.6.0
type CommonEventTests struct {
// contains filtered or unexported fields
}
CommonEventTests groups together event-related test methods that are shared between server-side and client-side.
func NewClientSideEventTests ¶ added in v1.6.0
func NewClientSideEventTests(testName string, baseSDKConfigurers ...SDKConfigurer) CommonEventTests
func NewServerSideEventTests ¶ added in v1.6.0
func NewServerSideEventTests(testName string, baseSDKConfigurers ...SDKConfigurer) CommonEventTests
func (CommonEventTests) AliasEvents ¶ added in v1.6.0
func (c CommonEventTests) AliasEvents(t *ldtest.T)
func (CommonEventTests) BufferBehavior ¶ added in v1.6.0
func (c CommonEventTests) BufferBehavior(t *ldtest.T)
func (CommonEventTests) CustomEvents ¶ added in v1.6.0
func (c CommonEventTests) CustomEvents(t *ldtest.T)
func (CommonEventTests) DisablingEvents ¶ added in v1.6.0
func (c CommonEventTests) DisablingEvents(t *ldtest.T)
func (CommonEventTests) EventUsers ¶ added in v1.6.0
func (c CommonEventTests) EventUsers(t *ldtest.T)
func (CommonEventTests) IdentifyEvents ¶ added in v1.6.0
func (c CommonEventTests) IdentifyEvents(t *ldtest.T)
func (CommonEventTests) RequestMethodAndHeaders ¶ added in v1.6.0
func (c CommonEventTests) RequestMethodAndHeaders(t *ldtest.T, headersMatcher m.Matcher)
func (CommonEventTests) RequestURLPath ¶ added in v1.6.0
func (c CommonEventTests) RequestURLPath(t *ldtest.T, pathMatcher m.Matcher)
func (CommonEventTests) UniquePayloadIDs ¶ added in v1.6.0
func (c CommonEventTests) UniquePayloadIDs(t *ldtest.T)
type CommonTagsTests ¶ added in v1.6.0
type CommonTagsTests struct {
// contains filtered or unexported fields
}
CommonTagsTests groups together event-related test methods that are shared between server-side and client-side.
func NewClientSideTagsTests ¶ added in v1.6.0
func NewClientSideTagsTests(testName string, baseSDKConfigurers ...SDKConfigurer) CommonTagsTests
func NewServerSideTagsTests ¶ added in v1.6.0
func NewServerSideTagsTests(testName string, baseSDKConfigurers ...SDKConfigurer) CommonTagsTests
func (CommonTagsTests) Run ¶ added in v1.6.0
func (c CommonTagsTests) Run(t *ldtest.T)
type FlagFactory ¶
type FlagFactory interface {
MakeFlag(param interface{}) ldmodel.FeatureFlag
}
func NewMemoizingFlagFactory ¶
func NewMemoizingFlagFactory(startingVersion int, factoryFn func(interface{}) ldmodel.FeatureFlag) FlagFactory
type FlagFactoryForValueTypes ¶
type FlagFactoryForValueTypes struct { KeyPrefix string BuilderActions func(*ldbuilders.FlagBuilder) ValueFactory ValueFactory Reason ldreason.EvaluationReason StartingVersion int // contains filtered or unexported fields }
func (*FlagFactoryForValueTypes) ForType ¶
func (f *FlagFactoryForValueTypes) ForType(valueType servicedef.ValueType) ldmodel.FeatureFlag
type MemoizingFlagFactory ¶
type MemoizingFlagFactory struct {
// contains filtered or unexported fields
}
func (*MemoizingFlagFactory) MakeFlag ¶
func (f *MemoizingFlagFactory) MakeFlag(param interface{}) ldmodel.FeatureFlag
type SDKClient ¶
type SDKClient struct {
// contains filtered or unexported fields
}
SDKClient represents an SDK client instance in the test service which can be controlled by test logic.
func NewSDKClient ¶
func NewSDKClient(t *ldtest.T, configurers ...SDKConfigurer) *SDKClient
NewSDKClient tells the test service to create an SDK client instance.
The first parameter should be the current test scope. Any error in creating the client will cause the test to fail and terminate immediately. Debug output related to the client will be attached to this test scope.
You must always specify at least one SDKConfigurer to customize the SDK configuration, since a default SDK configuration would only connect to LaunchDarkly which is normally not what we want. Test fixture components such as SDKDataSource implement this interface so that they can insert the appropriate base URIs into the configuration, so a common pattern is:
dataSource := NewSDKDataSource(t, ...) eventSink := NewSDKEventSink(t, ...) client := NewSDKClient(t, dataSource, eventSink)
Since the client will attempt to connect to its data source and possibly send events as soon as it starts up, the test fixtures must always be created first. You may reuse a previously created data source and event sink that was created in a parent test scope, if you do not need a new one for each client.
The object's lifecycle is tied to the test scope that created it; it will be automatically closed when this test scope exits. It can be reused by subtests until then.
func TryNewSDKClient ¶ added in v1.3.0
func TryNewSDKClient(t *ldtest.T, configurers ...SDKConfigurer) (*SDKClient, error)
func (*SDKClient) Close ¶ added in v1.3.0
Close tells the test service to shut down the client instance. Normally this happens automatically at the end of a test.
func (*SDKClient) EvaluateAllFlags ¶
func (c *SDKClient) EvaluateAllFlags( t *ldtest.T, params servicedef.EvaluateAllFlagsParams, ) servicedef.EvaluateAllFlagsResponse
EvaluateAllFlags tells the SDK client to evaluate all feature flags. This corresponds to calling the SDK's AllFlags or AllFlagsState method.
Any error from the test service causes the test to terminate immediately.
func (*SDKClient) EvaluateFlag ¶
func (c *SDKClient) EvaluateFlag(t *ldtest.T, params servicedef.EvaluateFlagParams) servicedef.EvaluateFlagResponse
EvaluateFlag tells the SDK client to evaluate a feature flag. This corresponds to calling one of the SDK's Variation or VariationDetail methods, depending on the parameters.
Any error from the test service causes the test to terminate immediately.
func (*SDKClient) FlushEvents ¶
FlushEvents tells the SDK client to initiate an event flush.
Any error from the test service causes the test to terminate immediately.
func (*SDKClient) GetBigSegmentStoreStatus ¶ added in v1.1.0
func (c *SDKClient) GetBigSegmentStoreStatus(t *ldtest.T) servicedef.BigSegmentStoreStatusResponse
GetBigSegmentStoreStatus queries the big segment store status from the SDK client. The test harness will only call this method if the test service has the "big-segments" capability.
func (*SDKClient) SendAliasEvent ¶
func (c *SDKClient) SendAliasEvent(t *ldtest.T, params servicedef.AliasEventParams)
SendAliasEvent tells the SDK client to send an alias event.
Any error from the test service causes the test to terminate immediately.
func (*SDKClient) SendCustomEvent ¶
func (c *SDKClient) SendCustomEvent(t *ldtest.T, params servicedef.CustomEventParams)
SendCustomEvent tells the SDK client to send a custom event.
Any error from the test service causes the test to terminate immediately.
type SDKConfigurer ¶
type SDKConfigurer helpers.ConfigOption[servicedef.SDKConfigParams]
SDKConfigurer is an interface for objects that can modify the configuration for StartSDKClient. It is implemented by types such as SDKDataSource.
func WithClientSideConfig ¶ added in v1.6.0
func WithClientSideConfig(clientSideConfig servicedef.SDKConfigClientSideParams) SDKConfigurer
WithClientSideConfig is used with StartSDKClient to specify a non-default client-side SDK configuration.
func WithConfig ¶
func WithConfig(config servicedef.SDKConfigParams) SDKConfigurer
WithConfig is used with StartSDKClient to specify a non-default SDK configuration. Use this before any other SDKConfigurers or it will overwrite their effects.
func WithCredential ¶ added in v1.6.0
func WithCredential(credential string) SDKConfigurer
WithCredential is used with StartSDKClient to set only the credential (SDK key, mobile key, or environment ID).
func WithEventsConfig ¶ added in v1.1.2
func WithEventsConfig(eventsConfig servicedef.SDKConfigEventParams) SDKConfigurer
WithEventsConfig is used with StartSDKClient to specify a non-default events configuration.
func WithServiceEndpointsConfig ¶ added in v1.5.0
func WithServiceEndpointsConfig(endpointsConfig servicedef.SDKConfigServiceEndpointsParams) SDKConfigurer
WithServiceEndpointsConfig is used with StartSDKClient to specify non-default service endpoints. This will only work if the test service has the "service-endpoints" capability.
func WithStreamingConfig ¶ added in v1.1.2
func WithStreamingConfig(streamingConfig servicedef.SDKConfigStreamingParams) SDKConfigurer
WithStreamingConfig is used with StartSDKClient to specify a non-default streaming configuration.
type SDKDataSource ¶
type SDKDataSource struct {
// contains filtered or unexported fields
}
SDKDataSource is a test fixture that provides a callback endpoint for SDK clients to connect to, simulating the LaunchDarkly streaming or polling service.
func NewSDKDataSource ¶
func NewSDKDataSource(t *ldtest.T, data mockld.SDKData, options ...SDKDataSourceOption) *SDKDataSource
NewSDKDataSource creates a new SDKDataSource with the specified initial data set.
It can simulate either the streaming service or the polling service. If you don't explicitly specify DataSourceOptionPolling or DataSourceOptionStreaming, the default depends on what kind of SDK is being tested: server-side and mobile SDKs default to streaming, JS-based client-side SDKs default to polling.
It automatically detects (from the ldtest.T properties) whether we are testing a server-side, mobile, or JS-based client-side SDK, and configures the endpoint behavior as appropriate. The endpoints will enforce that the client only uses supported URL paths and HTTP methods; however, they do not do any validation of credentials (SDK key, mobile key, environment ID) since that would require this component to know more about the overall configuration than it knows. We have specific tests that do verify that the SDKs send appropriate credentials.
The object's lifecycle is tied to the test scope that created it; it will be automatically closed when this test scope exits. It can be reused by subtests until then. Debug output related to the data source will be attached to this test scope.
func NewSDKDataSourceWithoutEndpoint ¶ added in v1.0.0
func NewSDKDataSourceWithoutEndpoint(t *ldtest.T, data mockld.SDKData, options ...SDKDataSourceOption) *SDKDataSource
NewSDKDataSourceWithoutEndpoint is the same as NewSDKDataSource, but it does not allocate an endpoint to accept incoming requests. Use this if you want to configure the endpoint separately, for instance if you want it to delegate some requests to the data source but return an error for some other requests.
func (*SDKDataSource) Configure ¶ added in v1.6.0
func (d *SDKDataSource) Configure(config *servicedef.SDKConfigParams) error
Configure updates the SDK client configuration for NewSDKClient, causing the SDK to connect to the appropriate base URI for the data source test fixture. This only works if the data source was created along with its own endpoint, with NewSDKDataSource; if it was created as a handler to be used in a separately configured endpoint, you have to set the base URI in the test logic rather than using this shortcut.
func (*SDKDataSource) Endpoint ¶ added in v1.0.0
func (d *SDKDataSource) Endpoint() *harness.MockEndpoint
Endpoint returns the low-level object that manages incoming requests.
func (*SDKDataSource) Handler ¶ added in v1.0.0
func (d *SDKDataSource) Handler() http.Handler
Handler returns the HTTP handler for the service. Since StreamingService implements http.Handler already, this is the same as Service() but makes the purpose clearer.
func (*SDKDataSource) PollingService ¶ added in v1.6.0
func (d *SDKDataSource) PollingService() *mockld.PollingService
PollingService returns the low-level object that manages the polling data, or nil if this is a streaming data source.
func (*SDKDataSource) StreamingService ¶ added in v1.6.0
func (d *SDKDataSource) StreamingService() *mockld.StreamingService
StreamingService returns the low-level object that manages the stream data, or nil if this is a polling data source.
type SDKDataSourceOption ¶ added in v1.6.0
type SDKDataSourceOption helpers.ConfigOption[sdkDataSourceConfig]
SDKDataSourceOption is the interface for options to NewSDKDataSource.
func DataSourceOptionPolling ¶ added in v1.6.0
func DataSourceOptionPolling() SDKDataSourceOption
DataSourceOptionPolling makes an SDKDataSource simulate the polling service.
func DataSourceOptionStreaming ¶ added in v1.6.0
func DataSourceOptionStreaming() SDKDataSourceOption
DataSourceOptionStreaming makes an SDKDataSource simulate the streaming service.
type SDKEventSink ¶
type SDKEventSink struct {
// contains filtered or unexported fields
}
SDKEventSink is a test fixture that provides a callback endpoint for SDK clients to send event data to, simulating the LaunchDarkly event-recorder service.
func NewSDKEventSink ¶
func NewSDKEventSink(t *ldtest.T) *SDKEventSink
NewSDKEventSink creates a new SDKEventSink.
It automatically detects (from the ldtest.T properties) whether we are testing a server-side, mobile, or JS-based client-side SDK, and configures the endpoint behavior as appropriate. The endpoints will enforce that the client only uses supported URL paths and HTTP methods; however, they do not do any validation of credentials (SDK key, mobile key, environment ID) since that would require this component to know more about the overall configuration than it knows. We have specific tests that do verify that the SDKs send appropriate credentials.
The object's lifecycle is tied to the test scope that created it; it will be automatically closed when this test scope exits. It can be reused by subtests until then. Debug output related to the event sink will be attached to this test scope, and also to any of its subtests that are active when the output is generated.
func (*SDKEventSink) Configure ¶ added in v1.6.0
func (e *SDKEventSink) Configure(config *servicedef.SDKConfigParams) error
Configure updates the SDK client configuration for NewSDKClient, causing the SDK to connect to the appropriate base URI for the test fixture.
func (*SDKEventSink) Endpoint ¶ added in v1.3.0
func (e *SDKEventSink) Endpoint() *harness.MockEndpoint
Endpoint returns the low-level object that manages incoming requests.
func (*SDKEventSink) ExpectAnalyticsEvents ¶
func (e *SDKEventSink) ExpectAnalyticsEvents(t require.TestingT, timeout time.Duration) mockld.Events
ExpectAnalyticsEvents waits for event data to be posted to the endpoint, and then calls matchers.ItemsInAnyOrder with the specified eventMatchers, verifying that the payload contains one event matching each of the matchers regardless of ordering.
If no new events arrive before the timeout, the test immediately fails and terminates.
The number of events posted must be the same as the number of matchers.
func (*SDKEventSink) ExpectNoAnalyticsEvents ¶
func (e *SDKEventSink) ExpectNoAnalyticsEvents(t require.TestingT, timeout time.Duration)
ExpectNoAnalyticsEvents waits for the specified timeout and fails if any events are posted before then.
func (*SDKEventSink) Service ¶ added in v1.1.0
func (e *SDKEventSink) Service() *mockld.EventsService
Service returns the underlying mock events service component, for access to special options.
type SDKTestContext ¶
type SDKTestContext struct {
// contains filtered or unexported fields
}
type UserFactory ¶
type UserFactory struct {
// contains filtered or unexported fields
}
func NewUserFactory ¶
func NewUserFactory(prefix string, builderActions ...func(lduser.UserBuilder)) *UserFactory
func (*UserFactory) NextUniqueUser ¶
func (f *UserFactory) NextUniqueUser() lduser.User
func (*UserFactory) NextUniqueUserMaybeAnonymous ¶ added in v1.1.0
func (f *UserFactory) NextUniqueUserMaybeAnonymous(shouldBeAnonymous bool) lduser.User
type ValueFactory ¶
func DefaultValueByTypeFactory ¶
func DefaultValueByTypeFactory() ValueFactory
func FlagValueByTypeFactory ¶
func FlagValueByTypeFactory() ValueFactory
func SingleValueFactory ¶
func SingleValueFactory(value ldvalue.Value) ValueFactory
Source Files ¶
- client_side_eval.go
- client_side_events_all.go
- client_side_tags.go
- common_tests_eval.go
- common_tests_events_alias.go
- common_tests_events_base.go
- common_tests_events_buffer.go
- common_tests_events_custom.go
- common_tests_events_disable.go
- common_tests_events_identify.go
- common_tests_events_request.go
- common_tests_events_users.go
- common_tests_tags.go
- constants.go
- custom_matchers_events.go
- custom_matchers_general.go
- helpers.go
- package_info.go
- server_side_big_segments.go
- server_side_data_store_updates.go
- server_side_eval.go
- server_side_eval_all_flags.go
- server_side_eval_bucketing.go
- server_side_events_all.go
- server_side_events_eval.go
- server_side_events_experimentation.go
- server_side_events_index.go
- server_side_events_summary.go
- server_side_service_endpoints.go
- server_side_stream_all.go
- server_side_stream_request.go
- server_side_stream_retry.go
- server_side_stream_validation.go
- server_side_tags.go
- testapi_context.go
- testapi_sdk_big_segments.go
- testapi_sdk_client.go
- testapi_sdk_data.go
- testapi_sdk_events.go
- testdata_factories.go
- testsuite_entry_point.go