mock

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockMAASServer

type MockMAASServer struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

MockMAASServer is a mock implementation of the MAAS API server for testing.

func NewMockMAASServer

func NewMockMAASServer(logger *logrus.Logger) *MockMAASServer

NewMockMAASServer creates a new mock MAAS API server.

func (*MockMAASServer) Close

func (m *MockMAASServer) Close()

Close closes the mock MAAS server.

func (*MockMAASServer) GetAPIKey

func (m *MockMAASServer) GetAPIKey() string

GetAPIKey returns a mock API key for the MAAS server.

func (*MockMAASServer) GetURL

func (m *MockMAASServer) GetURL() string

GetURL returns the URL of the mock MAAS server.

type MockMaasClient

type MockMaasClient struct {
	mock.Mock // Embedded mock.Mock
	// contains filtered or unexported fields
}

MockMaasClient is a mock implementation of the MAAS client for testing.

func NewMockMaasClient

func NewMockMaasClient(logger *logrus.Logger) *MockMaasClient

NewMockMaasClient creates a new mock MAAS client with test data.

func (*MockMaasClient) AllocateMachine

func (m *MockMaasClient) AllocateMachine(params *entity.MachineAllocateParams) (*models.Machine, error)

AllocateMachine allocates a machine based on constraints.

func (*MockMaasClient) ApplyStorageConstraints

func (m *MockMaasClient) ApplyStorageConstraints(systemID string, params models.StorageConstraintParams) error

ApplyStorageConstraints mock

func (*MockMaasClient) ApplyTagToMachine

func (m *MockMaasClient) ApplyTagToMachine(tagName, systemID string) error

ApplyTagToMachine applies a tag to a machine.

func (*MockMaasClient) CheckStorageConstraints

func (m *MockMaasClient) CheckStorageConstraints(machine *models.Machine, constraints *models.SimpleStorageConstraint) bool

CheckStorageConstraints checks if a machine meets the specified storage constraints. This is a mock implementation.

func (*MockMaasClient) CreateLogicalVolume

func (m *MockMaasClient) CreateLogicalVolume(systemID string, volumeGroupID int, params models.LogicalVolumeParams) (*models.LogicalVolume, error)

CreateLogicalVolume creates a new logical volume

func (*MockMaasClient) CreateMachinePartition

func (m *MockMaasClient) CreateMachinePartition(systemID string, blockDeviceID int, params modelsmaas.PartitionCreateParams) (*models.Partition, error)

CreateMachinePartition creates a partition on a block device for a specific machine.

func (*MockMaasClient) CreateRAID

func (m *MockMaasClient) CreateRAID(systemID string, params models.RAIDParams) (*models.RAID, error)

CreateRAID mock

func (*MockMaasClient) CreateTag

func (m *MockMaasClient) CreateTag(name, comment, definition string) (*models.Tag, error)

CreateTag creates a new tag.

func (*MockMaasClient) CreateVolumeGroup

func (m *MockMaasClient) CreateVolumeGroup(systemID string, params models.VolumeGroupParams) (*models.VolumeGroup, error)

CreateVolumeGroup creates a new volume group

func (*MockMaasClient) DeleteLogicalVolume

func (m *MockMaasClient) DeleteLogicalVolume(systemID string, volumeGroupID, logicalVolumeID int) error

DeleteLogicalVolume deletes a logical volume

func (*MockMaasClient) DeleteMachinePartition

func (m *MockMaasClient) DeleteMachinePartition(systemID string, blockDeviceID, partitionID int) error

DeleteMachinePartition deletes a partition from a block device for a specific machine.

func (*MockMaasClient) DeleteRAID

func (m *MockMaasClient) DeleteRAID(systemID string, raidID int) error

DeleteRAID mock

func (*MockMaasClient) DeleteStorageConstraints

func (m *MockMaasClient) DeleteStorageConstraints(systemID string) error

DeleteStorageConstraints mock

func (*MockMaasClient) DeleteVolumeGroup

func (m *MockMaasClient) DeleteVolumeGroup(systemID string, volumeGroupID int) error

DeleteVolumeGroup deletes a volume group

func (*MockMaasClient) DeployMachine

func (m *MockMaasClient) DeployMachine(systemID string, params *entity.MachineDeployParams) (*models.Machine, error)

DeployMachine deploys an allocated machine.

func (*MockMaasClient) FormatMachinePartition

func (m *MockMaasClient) FormatMachinePartition(systemID string, blockDeviceID, partitionID int, params map[string]interface{}) (*models.Filesystem, error)

FormatMachinePartition formats a partition on a block device for a specific machine.

func (*MockMaasClient) GetLogicalVolume

func (m *MockMaasClient) GetLogicalVolume(systemID string, volumeGroupID, logicalVolumeID int) (*models.LogicalVolume, error)

GetLogicalVolume retrieves a specific logical volume

func (*MockMaasClient) GetMachine

func (m *MockMaasClient) GetMachine(systemID string) (*models.Machine, error)

GetMachine retrieves details for a specific machine.

func (*MockMaasClient) GetMachineBlockDevice

func (m *MockMaasClient) GetMachineBlockDevice(systemID string, deviceID int) (*models.BlockDevice, error)

GetMachineBlockDevice retrieves a specific block device for a machine.

func (*MockMaasClient) GetMachineBlockDevices

func (m *MockMaasClient) GetMachineBlockDevices(systemID string) ([]models.BlockDevice, error)

GetMachineBlockDevices retrieves block devices for a specific machine.

func (*MockMaasClient) GetMachineInterfaces

func (m *MockMaasClient) GetMachineInterfaces(systemID string) ([]models.NetworkInterface, error)

GetMachineInterfaces retrieves network interfaces for a specific machine.

func (*MockMaasClient) GetMachineWithDetails

func (m *MockMaasClient) GetMachineWithDetails(ctx context.Context, systemID string, includeDetails bool) (*models.Machine, error)

GetMachineWithDetails retrieves details for a specific machine with optional detailed information. For mock, this can be similar to GetMachine.

func (*MockMaasClient) GetRAID

func (m *MockMaasClient) GetRAID(systemID string, raidID int) (*models.RAID, error)

GetRAID mock

func (*MockMaasClient) GetStorageConstraints

func (m *MockMaasClient) GetStorageConstraints(systemID string) (*models.StorageConstraintParams, error)

GetStorageConstraints mock

func (*MockMaasClient) GetSubnet

func (m *MockMaasClient) GetSubnet(id int) (*models.Subnet, error)

GetSubnet retrieves subnet details.

func (*MockMaasClient) GetVolumeGroup

func (m *MockMaasClient) GetVolumeGroup(systemID string, volumeGroupID int) (*models.VolumeGroup, error)

GetVolumeGroup retrieves a specific volume group

func (*MockMaasClient) ListMachines

func (m *MockMaasClient) ListMachines(ctx context.Context, filters map[string]string, pagination *maas.PaginationOptions) ([]models.Machine, int, error)

ListMachines retrieves machines based on filters with pagination.

func (*MockMaasClient) ListMachinesSimple

func (m *MockMaasClient) ListMachinesSimple(ctx context.Context, filters map[string]string) ([]models.Machine, error)

ListMachinesSimple retrieves machines based on filters without pagination.

func (*MockMaasClient) ListRAIDs

func (m *MockMaasClient) ListRAIDs(systemID string) ([]models.RAID, error)

ListRAIDs mock

func (*MockMaasClient) ListSubnets

func (m *MockMaasClient) ListSubnets() ([]models.Subnet, error)

ListSubnets retrieves all subnets.

func (*MockMaasClient) ListTags

func (m *MockMaasClient) ListTags() ([]models.Tag, error)

ListTags retrieves all tags.

func (*MockMaasClient) ListVLANs

func (m *MockMaasClient) ListVLANs(fabricID int) ([]models.VLAN, error)

ListVLANs retrieves all VLANs.

func (*MockMaasClient) ListVolumeGroups

func (m *MockMaasClient) ListVolumeGroups(systemID string) ([]models.VolumeGroup, error)

ListVolumeGroups retrieves all volume groups for a machine

func (*MockMaasClient) PowerOffMachine

func (m *MockMaasClient) PowerOffMachine(systemID string) (*models.Machine, error)

PowerOffMachine powers off a machine.

func (*MockMaasClient) PowerOnMachine

func (m *MockMaasClient) PowerOnMachine(systemID string) (*models.Machine, error)

PowerOnMachine powers on a machine.

func (*MockMaasClient) ReleaseMachine

func (m *MockMaasClient) ReleaseMachine(systemIDs []string, comment string) error

ReleaseMachine releases a machine back to the pool.

func (*MockMaasClient) RemoveTagFromMachine

func (m *MockMaasClient) RemoveTagFromMachine(tagName, systemID string) error

RemoveTagFromMachine removes a tag from a machine.

func (*MockMaasClient) ResizeLogicalVolume

func (m *MockMaasClient) ResizeLogicalVolume(systemID string, volumeGroupID, logicalVolumeID int, newSize int64) (*models.LogicalVolume, error)

ResizeLogicalVolume resizes a logical volume

func (*MockMaasClient) SetFailNextCall

func (m *MockMaasClient) SetFailNextCall(fail bool, operation string)

SetFailNextCall sets whether the next call should fail.

func (*MockMaasClient) SetStorageConstraints

func (m *MockMaasClient) SetStorageConstraints(systemID string, params models.StorageConstraintParams) error

SetStorageConstraints mock

func (*MockMaasClient) UpdateMachinePartition

func (m *MockMaasClient) UpdateMachinePartition(systemID string, blockDeviceID, partitionID int, params map[string]interface{}) (*models.Partition, error)

UpdateMachinePartition updates a partition on a block device for a specific machine.

func (*MockMaasClient) UpdateRAID

func (m *MockMaasClient) UpdateRAID(systemID string, raidID int, params models.RAIDUpdateParams) (*models.RAID, error)

UpdateRAID mock

func (*MockMaasClient) ValidateStorageConstraints

func (m *MockMaasClient) ValidateStorageConstraints(systemID string, params models.StorageConstraintParams) (bool, []string, error)

ValidateStorageConstraints mock

Jump to

Keyboard shortcuts

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