testing

package
v0.0.0-...-1f8c1e5 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: AGPL-3.0 Imports: 41 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DomainServicesGetterFunc

type DomainServicesGetterFunc func(model.UUID) services.DomainServices

DomainServicesGetterFunc is a convenience type for translating a getter function into the DomainServicesGetter interface.

func (DomainServicesGetterFunc) ServicesForModel

func (s DomainServicesGetterFunc) ServicesForModel(modelUUID model.UUID) services.DomainServices

ServicesForModel implements the DomainServicesGetter interface.

type DomainServicesSuite

type DomainServicesSuite struct {
	schematesting.ControllerModelSuite

	// AdminUserUUID is the uuid of the admin user made during the setup of this
	// test suite.
	AdminUserUUID coreuser.UUID

	// CloudName is the name of the cloud made during the setup of this suite.
	CloudName string

	// CloudType represents the type of the cloud made during the setup of this
	// suite.
	CloudType string

	CredentialKey credential.Key

	// ControllerModelUUID is the unique id for the controller model. If not set
	// will be set during test set up.
	ControllerModelUUID model.UUID

	// ControllerConfig is the controller configuration, including its UUID. If
	// not set will be set to the default testing value during test set up.
	ControllerConfig controller.Config

	// DefaultModelUUID is the unique id for the default model. If not set
	// will be set during test set up.
	DefaultModelUUID model.UUID

	// ProviderTracker is the provider tracker to use in the domain services.
	ProviderTracker providertracker.ProviderFactory
}

DomainServicesSuite is a test suite that can be composed into tests that require a Juju DomainServices and database access. It holds the notion of a controller model uuid and that of a default model uuid. Both of these models will be instantiated into the database upon test setup.

func (*DomainServicesSuite) ControllerDomainServices

func (s *DomainServicesSuite) ControllerDomainServices(c *gc.C) services.DomainServices

ControllerDomainServices conveniently constructs a domain services for the controller model.

func (*DomainServicesSuite) DefaultModelDomainServices

func (s *DomainServicesSuite) DefaultModelDomainServices(c *gc.C) services.DomainServices

DefaultModelDomainServices conveniently constructs a domain services for the default model.

func (*DomainServicesSuite) DomainServicesGetter

func (s *DomainServicesSuite) DomainServicesGetter(c *gc.C, objectStore objectstore.ObjectStore, leaseManager lease.Checker) DomainServicesGetterFunc

DomainServicesGetter provides an implementation of the DomainServicesGetter interface to use in tests. This includes the dummy storage registry.

func (*DomainServicesSuite) DomainServicesGetterWithStorageRegistry

func (s *DomainServicesSuite) DomainServicesGetterWithStorageRegistry(c *gc.C, objectStore objectstore.ObjectStore, leaseManager lease.Checker, storageRegistry storage.ProviderRegistry) DomainServicesGetterFunc

DomainServicesGetterWithStorageRegistry provides an implementation of the DomainServicesGetterWithStorageRegistry interface to use in tests with the additional storage provider.

func (*DomainServicesSuite) ModelDomainServices

func (s *DomainServicesSuite) ModelDomainServices(c *gc.C, modelUUID model.UUID) services.DomainServices

ModelDomainServices conveniently constructs a domain services for the default model.

func (*DomainServicesSuite) NoopLeaseManager

func (s *DomainServicesSuite) NoopLeaseManager(c *gc.C) lease.Checker

NoopLeaseManager returns a no-op implementation of lease.Checker.

func (*DomainServicesSuite) NoopObjectStore

func (s *DomainServicesSuite) NoopObjectStore(c *gc.C) objectstore.ObjectStore

NoopObjectStore returns a no-op implementation of the ObjectStore interface. This is useful when the test does not require any object store functionality.

func (*DomainServicesSuite) ObjectStoreServicesGetter

func (s *DomainServicesSuite) ObjectStoreServicesGetter(c *gc.C) ObjectStoreServicesGetterFunc

ObjectStoreServicesGetter provides an implementation of the ObjectStoreServicesGetter interface to use in tests.

func (*DomainServicesSuite) SeedAdminUser

func (s *DomainServicesSuite) SeedAdminUser(c *gc.C)

func (*DomainServicesSuite) SeedCloudAndCredential

func (s *DomainServicesSuite) SeedCloudAndCredential(c *gc.C)

func (*DomainServicesSuite) SeedControllerConfig

func (s *DomainServicesSuite) SeedControllerConfig(c *gc.C)

func (*DomainServicesSuite) SeedModelDatabases

func (s *DomainServicesSuite) SeedModelDatabases(c *gc.C)

SeedModelDatabases makes sure that model's for both the controller and default model have been created in the database.

func (*DomainServicesSuite) SetUpTest

func (s *DomainServicesSuite) SetUpTest(c *gc.C)

SetUpTest creates the controller and default model unique identifiers if they have not already been set. Also seeds the initial database with the models.

type ObjectStoreServicesGetterFunc

type ObjectStoreServicesGetterFunc func(model.UUID) services.ObjectStoreServices

ObjectStoreServicesGetterFunc is a convenience type for translating a getter function into the ObjectStoreServicesGetter interface.

func (ObjectStoreServicesGetterFunc) ServicesForModel

ServicesForModel implements the ObjectStoreServicesGetter interface.

type TestingLeaseManager

type TestingLeaseManager struct{}

TestingLeaseManager is a testing implementation of the lease.Checker interface. It returns canned responses for the methods.

func (TestingLeaseManager) Token

func (TestingLeaseManager) Token(leaseName, holderName string) lease.Token

Token returns a Token that can be interrogated at any time to discover whether the supplied lease is currently held by the supplied holder.

func (TestingLeaseManager) WaitUntilExpired

func (TestingLeaseManager) WaitUntilExpired(ctx context.Context, leaseName string, started chan<- struct{}) error

WaitUntilExpired returns nil when the named lease is no longer held. If it returns any error, no reasonable inferences may be made. The supplied context can be used to cancel the request; in this case, the method will return ErrWaitCancelled. The started channel when non-nil is closed when the wait begins.

type TestingLeaseManagerToken

type TestingLeaseManagerToken struct{}

TestingLeaseManagerToken is a testing implementation of the Token interface.

func (TestingLeaseManagerToken) Check

Check will always return lease.ErrNotHeld.

type TestingObjectStore

type TestingObjectStore struct{}

TestingObjectStore is a testing implementation of the ObjectStore interface.

func (TestingObjectStore) Get

Get returns an io.ReadCloser for data at path, namespaced to the model.

func (TestingObjectStore) GetBySHA256

func (TestingObjectStore) GetBySHA256(ctx context.Context, sha256 string) (io.ReadCloser, int64, error)

GetBySHA256 returns an io.ReadCloser for data at path, namespaced to the model.

func (TestingObjectStore) GetBySHA256Prefix

func (TestingObjectStore) GetBySHA256Prefix(ctx context.Context, sha256 string) (io.ReadCloser, int64, error)

GetBySHA256Prefix returns an io.ReadCloser for data at path, namespaced to the model.

func (TestingObjectStore) Put

Put stores data from reader at path, namespaced to the model.

func (TestingObjectStore) PutAndCheckHash

func (TestingObjectStore) PutAndCheckHash(ctx context.Context, path string, r io.Reader, size int64, hash string) (objectstore.UUID, error)

PutAndCheckHash stores data from reader at path, namespaced to the model. It also ensures the stored data has the correct hash.

func (TestingObjectStore) Remove

func (TestingObjectStore) Remove(ctx context.Context, path string) error

Remove removes data at path, namespaced to the model.

Jump to

Keyboard shortcuts

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