Documentation
¶
Index ¶
- Constants
- func CreateSimpleClient(t *testing.T, cfg *config_domain.GDGAppConfiguration, cfgName *string, ...) (ports.GrafanaService, *viper.Viper)
- func CreateSimpleClientWithConfig(t *testing.T, cfg *config_domain.GDGAppConfiguration, ...) ports.GrafanaService
- func InitOrganizations(t *testing.T, cfg *config_domain.GDGAppConfiguration) (testcontainers.Container, func() error)
- func InterceptStdout() (*os.File, *os.File, context.CancelFunc)
- func IsTokenBasedTest() bool
- func SetupAndExecuteMockingServices(t *testing.T, ...) (string, func())
- func SetupCloudFunctionOpt(cfgObj *config_domain.GDGAppConfiguration, encoder ports.CipherEncoder, ...) (context.Context, context.CancelFunc, ports.GrafanaService, ports.Storage, ...)
- func SkipEnterpriseTests(t *testing.T)
- func SkipTokenBasedTests(t *testing.T)
- func WithSecureAuth(auth config_domain.SecureModel) config_domain.GDGAppConfigurationOption
- type CloudTestOpt
- type InitContainerResult
Constants ¶
const ( GrafanaTestVersionEnv = "GRAFANA_TEST_VERSION" // #nosec G101 EnableTokenTestsEnv = "TEST_TOKEN_CONFIG" TestPlugSecretEnv = "TEST_PLUG_SECRET" FeatureEnabled = "1" FeatureDisabled = "0" )
const (
OrgNameOverride = "GDG_CONTEXTS__TESTING__ORGANIZATION_NAME"
)
Variables ¶
This section is empty.
Functions ¶
func CreateSimpleClient ¶
func CreateSimpleClient(t *testing.T, cfg *config_domain.GDGAppConfiguration, cfgName *string, container testcontainers.Container) (ports.GrafanaService, *viper.Viper)
CreateSimpleClient initializes a test Grafana client and Viper config for unit tests.
func CreateSimpleClientWithConfig ¶ added in v0.7.2
func CreateSimpleClientWithConfig(t *testing.T, cfg *config_domain.GDGAppConfiguration, container testcontainers.Container) ports.GrafanaService
CreateSimpleClientWithConfig creates a GrafanaService for tests using the provided config provider and testcontainers container.
func InitOrganizations ¶
func InitOrganizations(t *testing.T, cfg *config_domain.GDGAppConfiguration) (testcontainers.Container, func() error)
InitOrganizations will upload all known organizations and return the grafana container object
func InterceptStdout ¶ added in v0.7.2
InterceptStdout is a test helper function that will redirect all stdout in and out to a different file stream. It returns the stdout, stderr, and a function to be invoked to close the streams.
func IsTokenBasedTest ¶ added in v0.9.3
func IsTokenBasedTest() bool
IsTokenBasedTest returns true if the TEST_TOKEN_CONFIG environment variable is set to "1", indicating that token-based authentication tests should be run.
func SetupAndExecuteMockingServices ¶ added in v0.7.2
func SetupAndExecuteMockingServices(t *testing.T, process func(mock *mocks.GrafanaService, optionMockSvc func() domain.RootOption) error) (string, func())
SetupAndExecuteMockingServices will create a mock for varous required entities allowing to test the CLI flag parsing process: function that setups mocks and invokes the Execute command
func SetupCloudFunctionOpt ¶ added in v0.7.2
func SetupCloudFunctionOpt(cfgObj *config_domain.GDGAppConfiguration, encoder ports.CipherEncoder, opts ...CloudTestOpt) (context.Context, context.CancelFunc, ports.GrafanaService, ports.Storage, error)
SetupCloudFunctionOpt starts a S3 container, configures cloud storage for tests, and returns context, cancel func, Grafana service client, and error.
func SkipEnterpriseTests ¶ added in v0.9.3
func SkipTokenBasedTests ¶ added in v0.9.3
func WithSecureAuth ¶ added in v0.9.3
func WithSecureAuth(auth config_domain.SecureModel) config_domain.GDGAppConfigurationOption
Types ¶
type CloudTestOpt ¶ added in v0.7.2
func SetAccessKey ¶ added in v0.9.3
func SetAccessKey(val string) CloudTestOpt
SetAccessKey returns a CloudTestOpt that sets the access key (access ID) used for cloud storage authentication.
func SetBucketName ¶ added in v0.7.2
func SetBucketName(bucketName string) CloudTestOpt
SetBucketName sets the bucket name in the options map for cloud storage.
func SetCloudType ¶ added in v0.7.2
func SetCloudType(cloudType string) CloudTestOpt
SetCloudType sets the cloud type value in the map used for test options.
func SetPrefix ¶ added in v0.7.2
func SetPrefix(prefix string) CloudTestOpt
SetPrefix sets the cloud storage prefix key in the options map.
func SetSecretKey ¶ added in v0.9.3
func SetSecretKey(val string) CloudTestOpt
SetSecretKey returns a CloudTestOpt that sets the secret key configuration value to the provided string.
type InitContainerResult ¶ added in v0.8.0
type InitContainerResult struct {
ApiClient ports.GrafanaService
Container testcontainers.Container
CleanUp func() error
Err error
}
func InitTest ¶
func InitTest(t *testing.T, cfg *config_domain.GDGAppConfiguration, envProp map[string]string) *InitContainerResult
InitTest starts a Grafana test container, creates a client and optionally configures token auth. It returns an InitContainerResult with the client, container, cleanup function and error status.
func NewInitContainerResult ¶ added in v0.8.0
func NewInitContainerResult(client ports.GrafanaService, container testcontainers.Container, cleanUp func() error) *InitContainerResult
NewInitContainerResult creates an InitContainerResult linking a Grafana API client, container and cleanup function. It sets Err if the container is not running.