test

package
v0.0.0-...-6f15750 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockProviderClient

type MockProviderClient struct {
	Domains  map[string]core.CachedDomain
	Projects map[string]core.CachedProject
}

MockProviderClient implements the core.ProviderClientInterface.

func (MockProviderClient) CloudAdminClient

func (MockProviderClient) FindProjectID

func (c MockProviderClient) FindProjectID(_ context.Context, projectName, projectDomainName string) (string, error)

func (MockProviderClient) GetAuthResult

func (c MockProviderClient) GetAuthResult() gophercloud.AuthResult

func (MockProviderClient) GetDomain

func (c MockProviderClient) GetDomain(_ context.Context, domainID string) (*core.CachedDomain, error)

func (MockProviderClient) GetProject

func (c MockProviderClient) GetProject(_ context.Context, projectID string) (*core.CachedProject, error)

func (MockProviderClient) ProjectScopedClient

type Setup

type Setup struct {
	// for all types of integration tests
	Clock          *mock.Clock
	Config         core.Config
	DB             *gorp.DbMap
	ProviderClient MockProviderClient
	Team           core.AssetManagerTeam

	// for API tests only
	Auditor   *audittools.MockAuditor
	Handler   httptest.Handler
	Validator *mock.Validator[*mock.Enforcer]

	// for worker tests only
	Registry    *prometheus.Registry
	TaskContext *tasks.Context
}

Setup contains all the pieces that are needed for most tests.

func NewSetup

func NewSetup(t *testing.T, opts ...SetupOption) Setup

NewSetup prepares most or all pieces of Keppel for a test.

func (Setup) DBExec

func (s Setup) DBExec(query string, args ...any) error

DBExec is a shorthand for s.DB.Exec() that discards the unused return value.

func (Setup) DBUpdate

func (s Setup) DBUpdate(records ...any) error

DBUpdate is a shorthand for s.DB.Update() that discards the unused return value.

func (Setup) ManagerForAssetType

func (s Setup) ManagerForAssetType(assetType db.AssetType) *plugins.AssetManagerStatic

ManagerForAssetType return the mock asset manager for the given asset type, or panics if no such asset manager exists.

type SetupOption

type SetupOption func(*setupParams)

SetupOption is an option that can be given to NewSetup().

func WithAssetManagers

func WithAssetManagers(managers ...core.AssetManager) SetupOption

WithAssetManagers is a SetupOption that adds asset managers to the team.

func WithConfig

func WithConfig(configJSON string) SetupOption

WithConfig is a SetupOption that initializes core.Config by unmarshaling the provided JSON payload.

func WithDBFixtureFile

func WithDBFixtureFile(path string) SetupOption

WithDBFixtureFile is a SetupOption that initializes the DB by executing the given SQL file.

func WithSeveral

func WithSeveral(opts ...SetupOption) SetupOption

WithSeveral combines several SetupOption instances into a single object.

Jump to

Keyboard shortcuts

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