Documentation ¶
Overview ¶
Package testutils provides utility functions and behaviors for testing.
Package testutils provides utility functions and behaviors for testing.
Index ¶
- func CleanupPrivateBuses()
- func ExportAccountsMock(conn *dbus.Conn) error
- func ExportGdmMock(conn *dbus.Conn) error
- func ExportHostnameMock(conn *dbus.Conn) error
- func ExportLocaleMock(conn *dbus.Conn) error
- func ExportTimedateMock(conn *dbus.Conn) error
- func ExportUserMock(conn *dbus.Conn) error
- func GetSystemBusConnection() (*dbus.Conn, error)
- func GoldenPath(t *testing.T) string
- func InstallUpdateFlag()
- func LoadWithUpdateFromGolden(t *testing.T, data string, opts ...GoldenOption) string
- func LoadWithUpdateFromGoldenYAML[E any](t *testing.T, got E, opts ...GoldenOption) E
- func NewDbusConn(t *testing.T) *dbus.Conn
- func NormalizeGoldenName(t *testing.T, name string) string
- func ReadActionFromFile(opts ...Option) (string, error)
- func StartLocalSystemBus() func()
- func TestFamilyPath(t *testing.T) string
- func Update() bool
- func WriteActionToFile(action string, opts ...Option)
- type GoldenOption
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupPrivateBuses ¶
func CleanupPrivateBuses()
CleanupPrivateBuses cleans up the private buses created for testing.
func ExportAccountsMock ¶
func ExportAccountsMock(conn *dbus.Conn) error
ExportAccountsMock exports the accounts mock to the system bus.
func ExportGdmMock ¶
func ExportGdmMock(conn *dbus.Conn) error
ExportGdmMock exports a mock GDM Manager on the system bus.
func ExportHostnameMock ¶
func ExportHostnameMock(conn *dbus.Conn) error
ExportHostnameMock exports the hostname mock to the system bus.
func ExportLocaleMock ¶
func ExportLocaleMock(conn *dbus.Conn) error
ExportLocaleMock exports the locale mock to the system bus.
func ExportTimedateMock ¶
func ExportTimedateMock(conn *dbus.Conn) error
ExportTimedateMock exports the locale mock to the system bus.
func ExportUserMock ¶
func ExportUserMock(conn *dbus.Conn) error
ExportUserMock exports the user mock to the system bus.
func GetSystemBusConnection ¶
func GetSystemBusConnection() (*dbus.Conn, error)
GetSystemBusConnection returns a connection to the system bus with a safety check to avoid mistakenly connecting to the actual system bus.
func GoldenPath ¶
GoldenPath returns the golden path for the provided test.
func InstallUpdateFlag ¶
func InstallUpdateFlag()
InstallUpdateFlag install an update flag referenced in this package. The flags need to be parsed before running the tests.
func LoadWithUpdateFromGolden ¶
func LoadWithUpdateFromGolden(t *testing.T, data string, opts ...GoldenOption) string
LoadWithUpdateFromGolden loads the element from a plaintext golden file. It will update the file if the update flag is used prior to loading it.
func LoadWithUpdateFromGoldenYAML ¶
func LoadWithUpdateFromGoldenYAML[E any](t *testing.T, got E, opts ...GoldenOption) E
LoadWithUpdateFromGoldenYAML load the generic element from a YAML serialized golden file. It will update the file if the update flag is used prior to deserializing it.
func NewDbusConn ¶
NewDbusConn returns a system dbus connection which automatically close on test shutdown.
func NormalizeGoldenName ¶
NormalizeGoldenName returns the name of the golden file with illegal Windows characters replaced or removed.
func ReadActionFromFile ¶
ReadActionFromFile reads the action from a file, compared against goldenfiles to test the correct actions are being called.
func StartLocalSystemBus ¶
func StartLocalSystemBus() func()
StartLocalSystemBus allows to start and set environment variable to a local bus, preventing polluting system ones.
func TestFamilyPath ¶
TestFamilyPath returns the path of the dir for storing fixtures and other files related to the test.
func WriteActionToFile ¶
WriteActionToFile writes the action to a file, compared against goldenfiles to test the correct actions are being called.
Types ¶
type GoldenOption ¶
type GoldenOption func(*goldenOptions)
GoldenOption is a supported option reference to change the golden files comparison.
func WithGoldenPath ¶
func WithGoldenPath(path string) GoldenOption
WithGoldenPath overrides the default path for golden files used.