dbustest

package
v0.0.0-...-f890545 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connection

func Connection(handler DBusHandlerFunc) (*dbus.Conn, error)

Connection returns a DBus connection for writing unit tests.

The handler function is called for each message sent to the bus. It can return any number of messages to send in response.

func StubConnection

func StubConnection() (*dbus.Conn, error)

StubConnection returns a dbus connection that does nothing.

Using dbustest.Connection panics as the goroutines spawned by go-dbus do not expect the connection to be immediately closed.

Types

type DBusHandlerFunc

type DBusHandlerFunc func(msg *dbus.Message, n int) ([]*dbus.Message, error)

DBusHandlerFunc is the type of handler function for interacting with test DBus.

The handler is called for each message that arrives to the bus from the test client. The handler can respond by returning zero or more messages. Typically one message is returned (method response or error). Additional messages can be returned to represent signals emitted during message handling. The counter n aids in testing a sequence of messages that is expected.

The handler is not called for internal messages related to DBus itself.

type InjectMessageFunc

type InjectMessageFunc func(msg *dbus.Message)

func InjectableConnection

func InjectableConnection(handler DBusHandlerFunc) (*dbus.Conn, InjectMessageFunc, error)

InjectableConnection returns a DBus connection for writing unit tests and a function that can be used to inject messages that will be received by the test client.

Jump to

Keyboard shortcuts

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