test_tooling

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: BSD-3-Clause-LBNL Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GrafanaTestVersionEnv = "GRAFANA_TEST_VERSION"
	// #nosec G101
	EnableTokenTestsEnv = "TEST_TOKEN_CONFIG"
	FeatureEnabled      = "1"
	FeatureDisabled     = "0"
)
View Source
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

func InterceptStdout() (*os.File, *os.File, context.CancelFunc)

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

SetupCloudFunctionOpt starts a S3 container, configures cloud storage for tests, and returns context, cancel func, Grafana service client, and error.

func WrapTest added in v0.9.1

func WrapTest(f func())

Types

type CloudTestOpt added in v0.7.2

type CloudTestOpt func(m *map[string]string)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL