Help us shape the future of Go! Take the 2026 Go Developer Survey

fake

package
v1.148.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action is an int type alias.

const (
	// ActionDaemonReload is constant for the 'DaemonReload' action.
	ActionDaemonReload Action = iota
	// ActionDisable is constant for the 'Disable' action.
	ActionDisable
	// ActionEnable is constant for the 'Enable' action.
	ActionEnable
	// ActionRestart is constant for the 'Restart' action.
	ActionRestart
	// ActionStart is constant for the 'Start' action.
	ActionStart
	// ActionStop is constant for the 'Stop' action.
	ActionStop
	// ActionReboot is constant for the 'Reboot' action.
	ActionReboot
	// ActionList is constant for the 'List' action.
	ActionList
	// ActionListByNames is constant for the 'ListByNames' action.
	ActionListByNames
	// ActionGetUnitStateChangeTimestamp is constant for the 'GetUnitStateChangeTimestamp' action.
	ActionGetUnitStateChangeTimestamp
	// ActionGetTriggeredBy is constant for the 'GetTriggeredBy' action.
	ActionGetTriggeredBy
	// ActionGetServiceType is constant for the 'GetServiceType' action.
	ActionGetServiceType
)

type DBus

type DBus struct {
	Actions []SystemdAction
	// contains filtered or unexported fields
}

DBus is a fake implementation for the dbus.DBus interface.

func New

func New() *DBus

New returns a simple implementation of dbus.DBus which can be used to fake the dbus actions in unit tests.

func (*DBus) AddUnitsToList added in v1.119.0

func (d *DBus) AddUnitsToList(units ...systemddbus.UnitStatus)

AddUnitsToList adds the given units to the list of units that will be returned by List.

func (*DBus) DaemonReload

func (d *DBus) DaemonReload(_ context.Context) error

DaemonReload implements dbus.DBus.

func (*DBus) Disable

func (d *DBus) Disable(_ context.Context, unitNames ...string) error

Disable implements dbus.DBus.

func (*DBus) Enable

func (d *DBus) Enable(_ context.Context, unitNames ...string) error

Enable implements dbus.DBus.

func (*DBus) GetServiceType

func (d *DBus) GetServiceType(_ context.Context, unitName string) (string, error)

GetServiceType implements dbus.DBus.

func (*DBus) GetTriggeredBy

func (d *DBus) GetTriggeredBy(_ context.Context, unitName string) ([]string, error)

GetTriggeredBy implements dbus.DBus.

func (*DBus) GetUnitStateChangeTimestamp

func (d *DBus) GetUnitStateChangeTimestamp(_ context.Context, unitName string) (time.Time, error)

GetUnitStateChangeTimestamp implements dbus.DBus.

func (*DBus) InjectRestartFailure added in v1.111.0

func (d *DBus) InjectRestartFailure(err error, unitNames ...string)

InjectRestartFailure returns the given error the first time a restart is triggered on the given units.

func (*DBus) List added in v1.119.0

func (d *DBus) List(_ context.Context) ([]systemddbus.UnitStatus, error)

List implements dbus.DBus.

func (*DBus) ListByNames

func (d *DBus) ListByNames(_ context.Context, unitNames []string) ([]systemddbus.UnitStatus, error)

ListByNames implements dbus.DBus.

func (*DBus) Reboot added in v1.87.0

func (d *DBus) Reboot() error

Reboot implements dbus.DBus.

func (*DBus) Restart

func (d *DBus) Restart(_ context.Context, _ events.EventRecorder, _ runtime.Object, unitName string) error

Restart implements dbus.DBus.

func (*DBus) SetServiceType

func (d *DBus) SetServiceType(unitName, serviceType string)

SetServiceType sets the service type that will be returned for the given unit.

func (*DBus) SetTriggeredBy

func (d *DBus) SetTriggeredBy(unitName string, triggers []string)

SetTriggeredBy sets the TriggeredBy list that will be returned for the given unit.

func (*DBus) SetUnitStateChangeTimestamp

func (d *DBus) SetUnitStateChangeTimestamp(unitName string, timestamp time.Time)

SetUnitStateChangeTimestamp sets the state change timestamp that will be returned for the given unit.

func (*DBus) SetUnits

func (d *DBus) SetUnits(units ...systemddbus.UnitStatus)

SetUnits replaces the list of units that will be returned by List and ListByNames.

func (*DBus) Start

func (d *DBus) Start(_ context.Context, _ events.EventRecorder, _ runtime.Object, unitName string) error

Start implements dbus.DBus.

func (*DBus) Stop

func (d *DBus) Stop(_ context.Context, _ events.EventRecorder, _ runtime.Object, unitName string) error

Stop implements dbus.DBus.

type SystemdAction

type SystemdAction struct {
	Action    Action
	UnitNames []string
}

SystemdAction is used for the implementation of the fake dbus.

Jump to

Keyboard shortcuts

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