Documentation
¶
Index ¶
- Constants
- func CreateSimpleClient(t *testing.T, cfg *domain.GDGAppConfiguration, cfgName *string, ...) (service.GrafanaService, *viper.Viper)
- func CreateSimpleClientWithConfig(t *testing.T, cfg *domain.GDGAppConfiguration, ...) service.GrafanaService
- func InitOrganizations(t *testing.T, cfg *domain.GDGAppConfiguration) (testcontainers.Container, func() error)
- func InterceptStdout() (*os.File, *os.File, context.CancelFunc)
- func MaintainConfigAuth(cfg *domain.GDGAppConfiguration, configVal string)
- func SetupAndExecuteMockingServices(t *testing.T, ...) (string, func())
- func SetupCloudFunctionOpt(cfgObj *domain.GDGAppConfiguration, opts ...CloudTestOpt) (context.Context, context.CancelFunc, service.GrafanaService, storage.Storage, ...)
- func WrapTest(f func())
- type CloudTestOpt
- type InitContainerResult
Constants ¶
const ( GrafanaTestVersionEnv = "GRAFANA_TEST_VERSION" // #nosec G101 EnableTokenTestsEnv = "TEST_TOKEN_CONFIG" 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 *domain.GDGAppConfiguration, cfgName *string, container testcontainers.Container) (service.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 *domain.GDGAppConfiguration, container testcontainers.Container) service.GrafanaService
CreateSimpleClientWithConfig creates a GrafanaService for tests using the provided config provider and testcontainers container.
func InitOrganizations ¶
func InitOrganizations(t *testing.T, cfg *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 MaintainConfigAuth ¶ added in v0.9.1
func MaintainConfigAuth(cfg *domain.GDGAppConfiguration, configVal string)
MaintainConfigAuth updates Grafana config auth, preserving existing secure data during init.
func SetupAndExecuteMockingServices ¶ added in v0.7.2
func SetupAndExecuteMockingServices(t *testing.T, process func(mock *mocks.GrafanaService, optionMockSvc func() support.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 *domain.GDGAppConfiguration, opts ...CloudTestOpt) (context.Context, context.CancelFunc, service.GrafanaService, storage.Storage, error)
SetupCloudFunctionOpt starts a S3 container, configures cloud storage for tests, and returns context, cancel func, Grafana service client, and error.
Types ¶
type CloudTestOpt ¶ added in v0.7.2
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.
type InitContainerResult ¶ added in v0.8.0
type InitContainerResult struct {
ApiClient service.GrafanaService
Container testcontainers.Container
CleanUp func() error
Err error
}
func InitTest ¶
func InitTest(t *testing.T, cfg *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 service.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.