test

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 66 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateNetworks added in v0.0.3

func AllocateNetworks(t testing.TB, testStore *testStore, nws []*apiv2.NetworkServiceCreateRequest) map[string]*apiv2.Network

func CreateFilesystemLayouts added in v0.0.6

func CreateFilesystemLayouts(t testing.TB, testStore *testStore, fsls []*adminv2.FilesystemServiceCreateRequest) map[string]*apiv2.FilesystemLayout

func CreateIPs

func CreateIPs(t testing.TB, testStore *testStore, ips []*apiv2.IPServiceCreateRequest) map[string]*apiv2.IP

func CreateImages

func CreateImages(t testing.TB, testStore *testStore, images []*adminv2.ImageServiceCreateRequest) map[string]*apiv2.Image

func CreateMachines added in v0.0.6

func CreateMachines(t testing.TB, testStore *testStore, machines []*metal.Machine) map[string]*metal.Machine

func CreateMachinesWithAllocation added in v0.0.6

func CreateMachinesWithAllocation(t testing.TB, testStore *testStore, machines []*apiv2.MachineServiceCreateRequest) map[string]*apiv2.Machine

func CreateNetworks

func CreateNetworks(t testing.TB, testStore *testStore, nws []*adminv2.NetworkServiceCreateRequest) map[string]*apiv2.Network

func CreatePartitions

func CreatePartitions(t testing.TB, testStore *testStore, partitions []*adminv2.PartitionServiceCreateRequest) map[string]*apiv2.Partition

func CreateProjectInvites added in v0.0.6

func CreateProjectInvites(t testing.TB, testStore *testStore, invites []*apiv2.ProjectInvite)

func CreateProjectMemberships added in v0.0.6

func CreateProjectMemberships(t testing.TB, testStore *testStore, project string, memberships []*api.ProjectMemberCreateRequest)

func CreateProjects

func CreateProjects(t testing.TB, testStore *testStore, projects []*apiv2.ProjectServiceCreateRequest) map[string]string

func CreateSizeImageConstraints added in v0.1.7

func CreateSizeImageConstraints(t testing.TB, testStore *testStore, sizeImageConstraints []*adminv2.SizeImageConstraintServiceCreateRequest) map[string]*apiv2.SizeImageConstraint

func CreateSizeReservations added in v0.1.3

func CreateSizeReservations(t testing.TB, testStore *testStore, sizeReservations []*adminv2.SizeReservationServiceCreateRequest) map[string]*apiv2.SizeReservation

func CreateSizes added in v0.0.5

func CreateSizes(t testing.TB, testStore *testStore, sizes []*adminv2.SizeServiceCreateRequest) map[string]*apiv2.Size

func CreateSwitchStatuses added in v0.1.0

func CreateSwitchStatuses(t testing.TB, testStore *testStore, statuses []*api.SwitchStatus) map[string]*metal.SwitchStatus

func CreateSwitches added in v0.0.8

func CreateSwitches(t testing.TB, testStore *testStore, switches []*api.SwitchServiceCreateRequest) map[string]*apiv2.Switch

func CreateTenantInvites added in v0.0.6

func CreateTenantInvites(t testing.TB, testStore *testStore, invites []*apiv2.TenantInvite)

func CreateTenantMemberships added in v0.0.6

func CreateTenantMemberships(t testing.TB, testStore *testStore, tenant string, memberships []*api.TenantMemberCreateRequest)

func CreateTenants

func CreateTenants(t testing.TB, testStore *testStore, tenants []*apiv2.TenantServiceCreateRequest) []string

func DeleteIPs added in v0.0.6

func DeleteIPs(t testing.TB, testStore *testStore)

func DeleteMachines added in v0.0.6

func DeleteMachines(t testing.TB, testStore *testStore)

func DeleteNetworks added in v0.0.3

func DeleteNetworks(t testing.TB, testStore *testStore)

func DhcpMachines added in v0.1.5

func DhcpMachines(t testing.TB, testStore *testStore, bootRequests []*infrav2.BootServiceDhcpRequest)

func RegisterMachines added in v0.1.5

func RegisterMachines(t testing.TB, testStore *testStore, registerRequests []*infrav2.BootServiceRegisterRequest)

func StartAsynqServer added in v0.0.3

func StartAsynqServer(t testing.TB, log *slog.Logger, repository *repository.Store, redis *redis.Client) func()

func StartHeadscale added in v0.1.2

func StartHeadscale(t testing.TB) (*headscale.Client, string, func())

func StartIpam

func StartIpam(t testing.TB) (ipamv1connect.IpamServiceClient, func())

func StartMasterdataInMemory

func StartMasterdataInMemory(t testing.TB, log *slog.Logger) (mdc.Client, *grpc.ClientConn, func())

func StartMasterdataWithPostgres added in v0.1.1

func StartMasterdataWithPostgres(t testing.TB, log *slog.Logger) (mdc.Client, *grpc.ClientConn, func())

func StartRepositoryWithCleanup added in v0.0.3

func StartRepositoryWithCleanup(t testing.TB, log *slog.Logger, testOpts ...testOpt) (*testStore, func())

func StartRethink

func StartRethink(t testing.TB, log *slog.Logger) (generic.Datastore, r.ConnectOpts, func())

func StartValkey

func StartValkey(t testing.TB, testOpts ...testOpt) (*redis.Client, valkeygo.Client, func())

func Validate added in v0.0.8

func Validate(t *testing.T, msg proto.Message, options ...protovalidate.ValidationOption)

func WithContainers added in v0.1.6

func WithContainers(with bool) *testOptContainer

WithContainers if set to false, no database containers are started, defaults to true.

func WithHeadscale added in v0.1.9

func WithHeadscale(with bool) *testOptHeadscale

WithRethink if set to true a rethink database container is started, defaults to false.

func WithMiniRedis added in v0.1.2

func WithMiniRedis(with bool) *testOptMiniRedis

func WithPostgres added in v0.1.1

func WithPostgres(with bool) *testOptPostgres

WithPostgres if set to true a postgres database container is started, defaults to false.

func WithRethink added in v0.1.6

func WithRethink(with bool) *testOptRethink

WithRethink if set to true a rethink database container is started, defaults to false.

func WithValkey added in v0.0.6

func WithValkey(with bool) *testOptValkey

WithValkey if set to true a valkey database container is started, defaults to false.

Types

type Asserters added in v0.1.8

type Asserters struct {
	Tenants        func(tenants map[string]*apiv2.Tenant)
	Projects       func(projects map[string][]*apiv2.Project)
	Partitions     func(partitions map[string]*apiv2.Partition)
	Sizes          func(sizes map[string]*apiv2.Size)
	Networks       func(networks map[string]*apiv2.Network)
	IPs            func(ips map[string]*apiv2.IP)
	Images         func(images map[string]*apiv2.Image)
	Switches       func(switches map[string]*apiv2.Switch)
	SwitchStatuses func(switchStatuses map[string]*metal.SwitchStatus)
	Machines       func(machines map[string]*apiv2.Machine)
}

type Datacenter added in v0.1.5

type Datacenter struct {
	// contains filtered or unexported fields
}

func NewDatacenter added in v0.1.5

func NewDatacenter(t testing.TB, log *slog.Logger, testOpts ...testOpt) *Datacenter

func (*Datacenter) Assert added in v0.1.8

func (dc *Datacenter) Assert(mods *Asserters, opts ...cmp.Option) error

Assert tests whether all of the intended changes (and no others) were applied to the database.

Usage:

Define modifier functions that express what changes you expect the functions you are testing to apply to the database. Run the functions you are testing. Call dc.Assert(mods) with the modifiers you defined. Assert will fetch all current entities from the database and apply the modifications to the current datacenter. If the results differ Assert will return an error containing the diff. A `-` in the diff indicates a field that was expected but is not present in the database. A `+` in the diff indicates a field that was unexpectedly present in the database.

func (*Datacenter) Cleanup added in v0.1.8

func (dc *Datacenter) Cleanup()

func (*Datacenter) Close added in v0.1.5

func (dc *Datacenter) Close()

func (*Datacenter) Create added in v0.1.5

func (dc *Datacenter) Create(spec *scenarios.DatacenterSpec)

func (*Datacenter) GetIPs added in v0.1.8

func (dc *Datacenter) GetIPs() map[string]*apiv2.IP

func (*Datacenter) GetImages added in v0.1.8

func (dc *Datacenter) GetImages() map[string]*apiv2.Image

func (*Datacenter) GetMachines added in v0.1.8

func (dc *Datacenter) GetMachines() map[string]*apiv2.Machine

func (*Datacenter) GetNetworks added in v0.1.8

func (dc *Datacenter) GetNetworks() map[string]*apiv2.Network

func (*Datacenter) GetPartitions added in v0.1.8

func (dc *Datacenter) GetPartitions() map[string]*apiv2.Partition

func (*Datacenter) GetProjects added in v0.1.8

func (dc *Datacenter) GetProjects() map[string][]*apiv2.Project

func (*Datacenter) GetSizes added in v0.1.8

func (dc *Datacenter) GetSizes() map[string]*apiv2.Size

func (*Datacenter) GetSwitchStatuses added in v0.1.8

func (dc *Datacenter) GetSwitchStatuses() map[string]*metal.SwitchStatus

func (*Datacenter) GetSwitches added in v0.1.8

func (dc *Datacenter) GetSwitches() map[string]*apiv2.Switch

func (*Datacenter) GetTenants added in v0.1.8

func (dc *Datacenter) GetTenants() map[string]*apiv2.Tenant

func (*Datacenter) GetTestStore added in v0.1.8

func (dc *Datacenter) GetTestStore() *testStore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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