...

Source file src/github.com/launchdarkly/go-server-sdk/v6/internal/sharedtest/test_context.go

Documentation: github.com/launchdarkly/go-server-sdk/v6/internal/sharedtest

     1  package sharedtest
     2  
     3  import (
     4  	"github.com/launchdarkly/go-server-sdk/v6/subsystems"
     5  )
     6  
     7  // NewSimpleTestContext returns a basic implementation of interfaces.ClientContext for use in test code.
     8  func NewSimpleTestContext(sdkKey string) subsystems.ClientContext {
     9  	return NewTestContext(sdkKey, nil, nil)
    10  }
    11  
    12  // NewTestContext returns a basic implementation of interfaces.ClientContext for use in test code.
    13  // We can't use internal.NewClientContextImpl for this because of circular references.
    14  func NewTestContext(
    15  	sdkKey string,
    16  	optHTTPConfig *subsystems.HTTPConfiguration,
    17  	optLoggingConfig *subsystems.LoggingConfiguration,
    18  ) subsystems.BasicClientContext {
    19  	ret := subsystems.BasicClientContext{SDKKey: sdkKey}
    20  	if optHTTPConfig != nil {
    21  		ret.HTTP = *optHTTPConfig
    22  	}
    23  	if optLoggingConfig != nil {
    24  		ret.Logging = *optLoggingConfig
    25  	} else {
    26  		ret.Logging = TestLoggingConfig()
    27  	}
    28  	return ret
    29  }
    30  
    31  // TestLoggingConfig returns a LoggingConfiguration corresponding to NewTestLoggers().
    32  func TestLoggingConfig() subsystems.LoggingConfiguration {
    33  	return subsystems.LoggingConfiguration{Loggers: NewTestLoggers()}
    34  }
    35  

View as plain text